Hankey, Chris | 3 May 00:34 2011

Log Files Role Over After 1 Entry

We have an issue where log4net is rolling over log  files after one entry.  So based upon the config below, we end up with 25 1k log files.  This does not always happen.  The pattern seems to be that when we restart the site, log4net either works OK or does not & continues that way until we restart the app pool again.  Any clues?  We are using v 1.2.1

 

 

 

Thanks

 

Chris

 

 

  <log4net>

    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">

      <file value="E:\\Websites\\ABD\\ABDLog\\prodjune10\\TestLog.txt" />

      <appendToFile value="true" />

      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />

      <RollingStyle value="Composite" />

      <DatePattern value="yyyyMMdd" />

      <maximumFileSize value="8MB" />

      <maxSizeRollBackups value="25" />

      <layout type="log4net.Layout.PatternLayout">

        <conversionPattern value="%level %date %-4timestamp {%thread} [%logger] - %message%newline" />

      </layout>

    </appender>

 

Svante Seleborg | 3 May 07:36 2011

Re: Log Files Role Over After 1 Entry

You are probably logging from several AppDomains to the same log file. This is not really supported by Log4Net, not even with the 'minimal' locking style. Try the http://log4netremotelogging.codeplex.com/ which solves this and other issues whith several log sources.
 
Svante

On Tue, May 3, 2011 at 12:34 AM, Hankey, Chris <Chris.Hankey <at> transamerica.com> wrote:

We have an issue where log4net is rolling over log  files after one entry.  So based upon the config below, we end up with 25 1k log files.  This does not always happen.  The pattern seems to be that when we restart the site, log4net either works OK or does not & continues that way until we restart the app pool again.  Any clues?  We are using v 1.2.1

 

 

 

Thanks

 

Chris

 

 

  <log4net>

    <appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">

      <file value="E:\\Websites\\ABD\\ABDLog\\prodjune10\\TestLog.txt" />

      <appendToFile value="true" />

      <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />

      <RollingStyle value="Composite" />

      <DatePattern value="yyyyMMdd" />

      <maximumFileSize value="8MB" />

      <maxSizeRollBackups value="25" />

      <layout type="log4net.Layout.PatternLayout">

        <conversionPattern value="%level %date %-4timestamp {%thread} [%logger] - %message%newline" />

      </layout>

    </appender>

 


Chris Jansen | 4 May 00:29 2011
Picon

Custom string match filter stopped working

I created a custom string match filter to *not* log lines that match a specified string, rather than log filter matches like StringMatchFilter. I also added logic to search the exception if it exists. The logic is all in the Decide method (see code below).

We have a production environment where we're using log4net with Web services. The filter has been working fine for a few weeks until a couple of days ago. Now, for some reason, one of the filters is no longer working. It could be that none of them are working anymore, but we're consistently seeing log messages from one of the filters.

Any idea what might cause this? The custom filter Decide method can be viewed here: http://pastebin.com/1PZhyDJd

Thanks.

Lee Chun Kit | 4 May 06:06 2011
Picon

Re: Custom string match filter stopped working

Should it be that
FilterDecision.Accept : FilterDecision.Deny
at lines 35, 47 be reversed into
FilterDecision.Deny : FilterDecision.Accept
?

Regards,
Chun Kit

p.s. IMHO, the pastebin should be set not to expire so that others who
read this mailing list in the future can benefit.

On Wed, May 4, 2011 at 6:29 AM, Chris Jansen <chrisj732 <at> gmail.com> wrote:
> I created a custom string match filter to *not* log lines that match a
> specified string, rather than log filter matches like StringMatchFilter. I
> also added logic to search the exception if it exists. The logic is all in
> the Decide method (see code below).
>
> We have a production environment where we're using log4net with Web
> services. The filter has been working fine for a few weeks until a couple of
> days ago. Now, for some reason, one of the filters is no longer working. It
> could be that none of them are working anymore, but we're consistently
> seeing log messages from one of the filters.
>
> Any idea what might cause this? The custom filter Decide method can be
> viewed here: http://pastebin.com/1PZhyDJd
>
> Thanks.
>

Chris Jansen | 4 May 06:44 2011
Picon

Re: Custom string match filter stopped working


Good question, it depends on the configuration. Since _acceptOnMatch is false from the configuration, that's the way I want it:

  <filter type="log4net.Filter.StringMatchExceptionFilter">
      <stringToMatch value="is currently logged in" />
      <acceptOnMatch value="false" />
  </filter>


On Tue, May 3, 2011 at 10:06 PM, Lee Chun Kit <chunkit85 <at> gmail.com> wrote:
Should it be that
FilterDecision.Accept : FilterDecision.Deny
at lines 35, 47 be reversed into
FilterDecision.Deny : FilterDecision.Accept
?

Regards,
Chun Kit

p.s. IMHO, the pastebin should be set not to expire so that others who
read this mailing list in the future can benefit.

On Wed, May 4, 2011 at 6:29 AM, Chris Jansen <chrisj732 <at> gmail.com> wrote:
> I created a custom string match filter to *not* log lines that match a
> specified string, rather than log filter matches like StringMatchFilter. I
> also added logic to search the exception if it exists. The logic is all in
> the Decide method (see code below).
>
> We have a production environment where we're using log4net with Web
> services. The filter has been working fine for a few weeks until a couple of
> days ago. Now, for some reason, one of the filters is no longer working. It
> could be that none of them are working anymore, but we're consistently
> seeing log messages from one of the filters.
>
> Any idea what might cause this? The custom filter Decide method can be
> viewed here: http://pastebin.com/1PZhyDJd
>
> Thanks.
>

rebelrajesh | 18 May 11:41 2011
Picon

Log4Net adonet appender settings for oracle


 <log4net debug="true">
    <!--appender for DB logging-->
    <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
      <bufferSize value="1" />
      <connectionType
value="System.Data.OracleClient.OracleConnection,System.Data.OracleClient,
Version=2.0.0.0,Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <connectionString value="Data Source=localhost/ga;User
ID=re_3;Password=re_3" providerName="System.Data.OracleClient"/>
      <commandText value="INSERT INTO LOG4NET
(LOG_LEVEL,LOG_MESSAGE,LOG_DATE,LOGIN_ID, BROWSER_INFO,STACK_TRACE,
PAGE_URL,QUERY_STRING,IP_ADDRESS,EXP_SOURCE)
VALUES(:log_level,:log_message,to_timestamp(:log_date, 'dd-MM-yyyy
HH24:mi:ss.ff6'),:loginid,:browser_info,:stack_trace, :page_url,
:query_string, :ip_address,:exp_source)  " />

      <parameter>
        <parameterName value=":log_level" />
        <dbType value="String" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%level" />
        </layout>
      </parameter>

      <parameter>
        <parameterName value=":log_message" />
        <dbType value="String" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%m" />
        </layout>
      </parameter>

      <parameter>
        <parameterName value=":log_date" />
        <dbType value="String" />
        <layout type="log4net.Layout.PatternLayout"
value="%date{dd'-'MM'-'yyyy HH':'mm':'ss'.'ffffff}" />
      </parameter>

      <parameter>
        <parameterName value=":loginid" />
        <dbType value="string" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%property{LOGINID}" />
        </layout>
      </parameter>

      <parameter>
        <parameterName value=":browser_info" />
        <dbType value="string" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%property{Browser_Info}" />
        </layout>
      </parameter>

      <parameter>
        <parameterName value=":stack_trace" />
        <dbType value="String" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%property{STACK_TRACE}" />
        </layout>
      </parameter>

      <parameter>
        <parameterName value=":page_url" />
        <dbType value="string" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%property{Page_Url}" />
        </layout>
      </parameter>

      <parameter>
        <parameterName value=":query_string" />
        <dbType value="string" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%property{QUERY_STRING}" />
        </layout>
      </parameter>

      <parameter>
        <parameterName value=":ip_address" />
        <dbType value="string" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%property{IP_ADDRESS}" />
        </layout>
      </parameter>

      <parameter>
        <parameterName value=":exp_source" />
        <dbType value="string" />
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%property{EXP_SOURCE}" />
        </layout>
      </parameter>
    </appender>

    <root>
      <level value="debug"/>
      <appender-ref ref="AdoNetAppender"/>
    </root>

  </log4net>

---------------------------
Above log4net body is to be included in the web.config.
parameters which are specified with property in the conversion pattern like:
<conversionPattern value="%property{LOGINID}" /> are custom parameters.
Values for these parameters can be given using the below statements. They
are to be included in the appropriate .aspx.cs pages where we can get
values.

 log4net.GlobalContext.Properties["STACK_TRACE"] = ex.StackTrace.ToString();
log4net.GlobalContext.Properties["EXP_SOURCE"] = ex.TargetSite.ToString();

 log4net.GlobalContext.Properties["Page_Url"] =
System.Web.HttpContext.Current.Request.Url.AbsoluteUri;
                log4net.GlobalContext.Properties["QUERY_STRING"] =
System.Web.HttpContext.Current.Request.QueryString.ToString();

log4net.GlobalContext.Properties["LOGINID"] = user.Login;

 HttpBrowserCapabilities browser = Request.Browser;
                string browserInfo = "BrowserName:" + browser.Browser +
"<br>" + "BrowserType:" + browser.Type + "<br>" + " BrowserVersion:" +
browser.Version;
                log4net.GlobalContext.Properties["Browser_Info"] =
browserInfo;
                log4net.GlobalContext.Properties["IP_ADDRESS"] =
(string)System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

--

-- 
View this message in context: http://old.nabble.com/Log4Net-adonet-appender-settings-for-oracle-tp31645352p31645352.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

Rob Richardson | 24 May 17:36 2011

Too many log files

Log4net is ignoring the maximum number of files for my rolling file appender:

 

  <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">

    <file value="HeatingModelScheduler.log" />

    <appendToFile value="true" />

    <param name="MaxSizeRollBackups" value="5" />

    <param name="DatePattern" value=".yyyy-MM-dd.lo\g" />

    <layout type="log4net.Layout.PatternLayout">

      <conversionPattern value="%date - %message%newline" />

    </layout>

  </appender>

 

Why do I now have six old log files?

 

Thank you very much.

 

RobR

Lansdaal, Michael T | 24 May 18:33 2011
Picon

RE: Too many log files

This post (http://www.l4ndash.com/Log4NetMailArchive%2Ftabid%2F70%2Fforumid%2F1%2Fpostid%2F17575%2Fview%2Ftopic%2FDefault.aspx) says that maxSizeRollBackups does not work if you set RollingStyle to RollingMode.Date (and another post I saw says it as “rollingStyle of Date does not support maxSizeRollBackups).

 

I have implemented my own directory cleaning code in application to clean out log files older than a certain date.

 

Thanks, Mike

 

From: Rob Richardson [mailto:Rob.Richardson <at> rad-con.com]
Sent: Tuesday, May 24, 2011 8:37 AM
To: Log4NET User
Subject: Too many log files

 

Log4net is ignoring the maximum number of files for my rolling file appender:

 

  <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">

    <file value="HeatingModelScheduler.log" />

    <appendToFile value="true" />

    <param name="MaxSizeRollBackups" value="5" />

    <param name="DatePattern" value=".yyyy-MM-dd.lo\g" />

    <layout type="log4net.Layout.PatternLayout">

      <conversionPattern value="%date - %message%newline" />

    </layout>

  </appender>

 

Why do I now have six old log files?

 

Thank you very much.

 

RobR

Rob Richardson | 24 May 18:38 2011

RE: Too many log files

Thanks for your reply!  I quote a reply to that thread below:

 

I suspect the difficulties deleting files rolled only by date is that
the appender would need to take into account the DatePattern used when
locating files to be considered for deleting. Counted backups
(log.txt.1, log.txt.2, log.txt.3, etc.) are easier to deal with because
integer sequences are more well-known.

I'm not aware of any efforts to support rolling of files based on
RollingMode.Date.

 

I would be happy with counted backups, as mentioned in that reply.  How do I set my rolling file appender to do that?

 

Thanks again!

 

RobR

 

From: Lansdaal, Michael T [mailto:michael.t.lansdaal <at> boeing.com]
Sent: Tuesday, May 24, 2011 12:33 PM
To: Log4NET User
Subject: RE: Too many log files

 

This post (http://www.l4ndash.com/Log4NetMailArchive%2Ftabid%2F70%2Fforumid%2F1%2Fpostid%2F17575%2Fview%2Ftopic%2FDefault.aspx) says that maxSizeRollBackups does not work if you set RollingStyle to RollingMode.Date (and another post I saw says it as “rollingStyle of Date does not support maxSizeRollBackups).

 

I have implemented my own directory cleaning code in application to clean out log files older than a certain date.

 

Thanks, Mike

 

From: Rob Richardson [mailto:Rob.Richardson <at> rad-con.com]
Sent: Tuesday, May 24, 2011 8:37 AM
To: Log4NET User
Subject: Too many log files

 

Log4net is ignoring the maximum number of files for my rolling file appender:

 

  <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">

    <file value="HeatingModelScheduler.log" />

    <appendToFile value="true" />

    <param name="MaxSizeRollBackups" value="5" />

    <param name="DatePattern" value=".yyyy-MM-dd.lo\g" />

    <layout type="log4net.Layout.PatternLayout">

      <conversionPattern value="%date - %message%newline" />

    </layout>

  </appender>

 

Why do I now have six old log files?

 

Thank you very much.

 

RobR

Michael Schall | 24 May 18:57 2011
Picon

Re: Too many log files

I worked on a solution to this that we are using in production...  I posted it on the list without much response...  You are welcome to try this...

http://article.gmane.org/gmane.comp.apache.logging.log4net.devel/885/match=rolling+files+date+time+boundaries+doesn't+support+maximum+number+backup

On Tue, May 24, 2011 at 11:38 AM, Rob Richardson <Rob.Richardson <at> rad-con.com> wrote:

Thanks for your reply!  I quote a reply to that thread below:

 

I suspect the difficulties deleting files rolled only by date is that
the appender would need to take into account the DatePattern used when
locating files to be considered for deleting. Counted backups
(log.txt.1, log.txt.2, log.txt.3, etc.) are easier to deal with because
integer sequences are more well-known.

I'm not aware of any efforts to support rolling of files based on
RollingMode.Date.

 

I would be happy with counted backups, as mentioned in that reply.  How do I set my rolling file appender to do that?

 

Thanks again!

 

RobR

 

From: Lansdaal, Michael T [mailto:michael.t.lansdaal <at> boeing.com]
Sent: Tuesday, May 24, 2011 12:33 PM
To: Log4NET User
Subject: RE: Too many log files

 

This post (http://www.l4ndash.com/Log4NetMailArchive%2Ftabid%2F70%2Fforumid%2F1%2Fpostid%2F17575%2Fview%2Ftopic%2FDefault.aspx) says that maxSizeRollBackups does not work if you set RollingStyle to RollingMode.Date (and another post I saw says it as “rollingStyle of Date does not support maxSizeRollBackups).

 

I have implemented my own directory cleaning code in application to clean out log files older than a certain date.

 

Thanks, Mike

 

From: Rob Richardson [mailto:Rob.Richardson <at> rad-con.com]
Sent: Tuesday, May 24, 2011 8:37 AM
To: Log4NET User
Subject: Too many log files

 

Log4net is ignoring the maximum number of files for my rolling file appender:

 

  <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">

    <file value="HeatingModelScheduler.log" />

    <appendToFile value="true" />

    <param name="MaxSizeRollBackups" value="5" />

    <param name="DatePattern" value=".yyyy-MM-dd.lo\g" />

    <layout type="log4net.Layout.PatternLayout">

      <conversionPattern value="%date - %message%newline" />

    </layout>

  </appender>

 

Why do I now have six old log files?

 

Thank you very much.

 

RobR



Gmane