logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian Baker (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4NET-178) Log4Net stops logging after appdomain recycle of ASP.NET2.0 application
Date Mon, 15 Jun 2015 01:59:00 GMT

    [ https://issues.apache.org/jira/browse/LOG4NET-178?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14585366#comment-14585366
] 

Brian Baker commented on LOG4NET-178:
-------------------------------------

It isn't so much that events are happening out of order -- it is more of an issue of having
multiple processes trying to write to the same file. If you refer to the link I posted in
the previous comment, you can read a little bit more about how worker process recycling works.
Essentially, when IIS decides to recycle the app pool, it will spin up a new process and when
the new process is ready, IIS will start sending HTTP requests to it and start draining the
connections from the original process. If the requests are non-trivial and take a little time
to complete, this will result in two IIS worker processes running simultaneously. By default,
the file appender used by log4net in the first process will have an exclusive file lock on
the log file, so when the second process attempts to start locking it won't be able to get
a lock on the file.

You could also see from this explanation why putting an initialization step in the application
start event is not reliable. Chances are, if your app is under constant load, that the log
file will still be locked from the first process when the second one fires its start event.
An initialization in BeginRequest would eventually work but would surely have to much overhead,
I would think.

I suppose you could also try the approaches in the FAQ entry ["How do I get multiple process
to log to the same file?"|http://logging.apache.org/log4net/release/faq.html#single-file]
although we did not try any of those.

Alternatively, you could configure the log file name to include the process id so that there
would not be a conflict on the file name. However, this is usually not desirable from an operations
perspective.

> Log4Net stops logging after appdomain recycle of ASP.NET2.0 application
> -----------------------------------------------------------------------
>
>                 Key: LOG4NET-178
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-178
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 1.2.10
>         Environment: Windows server 2003
>            Reporter: Richard Nijkamp
>            Assignee: Dominik Psenner
>             Fix For: 1.2.12
>
>
> Dear sir/madam,
>  We are using Log4Net 1.2.10. We encounter the problem that Log4net doesn't continue
logging after an event that triggers an appdomain recycle/restart.
>  In the global.asax we start the logging with:
>  private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
> Logging works flawless when the application is started for the first time. After sometime
it might occur that the appdomain gets recycled due to inactivity of the web application.
We use the following code in Application_end():
> log.Info("*** Application end ***");
> log4net.LogManager.Shutdown();
> After this function the application gets restarted and the Application_start() method
executes and writes new lines to the log. The problem is that the log4net doesn't write the
new lines after the restart. Could you explain why log4net might stop working after an appdomain
restart of an asp.net2.0 web application? If I want log4net to work properly again I need
to restart IIS manually.
>  Looking forward to your reply.
> Best regards,
> Richard Nijkamp



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message