locked
Log4Net save in a rollingLogFileAppender when the AdoNetAppender can not connect to the database. RRS feed

  • Question

  • User-1228454064 posted

    Hi everyone,

    I have been looking for an answer to this question and I have found nothing.

    How can I configure Log4net to use a RollingLogFileAppender when the AdoNetAppender (configure it as the default) can not connect to the database or the connectionString is not the correct one?

    In order to clarify this, I have a WebService and I use log4net to save my logs into the database but I had a situation where the connection string had the wrong user and password, that thows an exception and when I tried to save the log of course nothing was saved because the log4net Ado appender uses the same connection string, If that happens, I would like to save the logs using another append.

    It could be using RollingLogFileAppender to get a log File.

    how can I accomplish this ? 

     

    Thursday, August 16, 2018 7:21 PM

Answers

  • User-1811426859 posted
    So you need the dynamically update connection string :
    https://stackoverflow.com/questions/18112762/setting-up-dynamic-connection-string-for-log4net
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 17, 2018 7:04 AM
  • User1120430333 posted

    There is no solution for this, other than, you doing some kind of test check for the connectivity to the database and terminate the program if the connectivity check fails.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 27, 2018 6:31 PM

All replies

  • User-1811426859 posted
    So you need the dynamically update connection string :
    https://stackoverflow.com/questions/18112762/setting-up-dynamic-connection-string-for-log4net
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 17, 2018 7:04 AM
  • User-1228454064 posted

    hi WatcherR, I done that already, my questions is more like if It's possible to use an extra way to logging (like write in a file) when I do not have access to the database.

    Imagine a desktop app and there is not network connection, so I can't save my logs on the database, Is there a way using log4net where I can say "ok if you cannot save the log on the database, well use this another appender"?

    does it make sense ? 

    thanks.

    Monday, August 27, 2018 5:22 PM
  • User1120430333 posted

    There is no solution for this, other than, you doing some kind of test check for the connectivity to the database and terminate the program if the connectivity check fails.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 27, 2018 6:31 PM