David Gerler | 1 Dec 2009 01:20
Picon

Using RollingFileAppender with style=Date.

How do I make it only keep a certain number of files when using the rollingstyle = date? I’ve looked on the website and have not been able to find an example of anything talking about it. This is what I have now:

 

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

                <file value="c:/log/register/gis/communications.txt" />

                <appendToFile value="true" />

                 <maxSizeRollBackups value="10" />

<rollingStyle value="Date" />

                 <datePattern value="yyyyMMdd-HHmm" />

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

                                <header value="[Header]&#xD;&#xA;" />

                                <footer value="[Footer]&#xD;&#xA;" />

                                <conversionPattern value="%date [%thread] %-5level %logger (%file:%line) - %message%newline" />

                </layout>

    </appender>

 

It doesn’t delete the files when I get to 10.

Tiernan OToole | 1 Dec 2009 15:12
Picon

.NET 4.0 and Log4Net

Good morning all.
 
when trying to use Log4Net (1.2.10) with .NET 4.0, i am getting an error about Log4Net needing System.Web... is this a known issue?

--
Tiernan O'Toole
blog.lotas-smartman.net
www.tiernanotoolephotography.com
www.the-hairy-one.com
Ron Grabowski | 2 Dec 2009 03:25
Picon
Favicon

Re: .NET 4.0 and Log4Net

Well, its a known issue in the sense that its had that dependency for 8+ years: System.Web.Mail

From: Tiernan OToole <lsmartman <at> gmail.com>
To: log4net-user <at> logging.apache.org
Sent: Tue, December 1, 2009 9:12:55 AM
Subject: .NET 4.0 and Log4Net

Good morning all.
 
when trying to use Log4Net (1.2.10) with .NET 4.0, i am getting an error about Log4Net needing System.Web... is this a known issue?

--
Tiernan O'Toole
blog.lotas-smartman.net
www.tiernanotoolephotography.com
www.the-hairy-one.com
Roy Chastain | 2 Dec 2009 13:19

RE: .NET 4.0 and Log4Net

Well, actually, if you compile with NET_2_0 defined for use with .Net
2.0, it uses System.Net.Mail.

However, the ASPNetTraceAppender does reference the System.Web namespace
for access to the HttpContext class.

In both versions 2.0 and 4.0 of the framework, this class is in
System.Web.dll so there should be no difference from current
development.

----------------------------------------------------------------------
Roy Chastain

-----Original Message-----
From: Ron Grabowski [mailto:rongrabowski <at> yahoo.com] 
Sent: Tuesday, December 01, 2009 21:26
To: Log4NET User
Subject: Re: .NET 4.0 and Log4Net

Well, its a known issue in the sense that its had that dependency for 8+
years: System.Web.Mail

________________________________

From: Tiernan OToole <lsmartman <at> gmail.com>
To: log4net-user <at> logging.apache.org
Sent: Tue, December 1, 2009 9:12:55 AM
Subject: .NET 4.0 and Log4Net

Good morning all.

when trying to use Log4Net (1.2.10) with .NET 4.0, i am getting an error
about Log4Net needing System.Web... is this a known issue?

--

-- 
Tiernan O'Toole
blog.lotas-smartman.net
www.tiernanotoolephotography.com
www.the-hairy-one.com

Tiernan OToole | 2 Dec 2009 14:04
Picon

Re: RE: .NET 4.0 and Log4Net

I am trying to use the compiled dll from the website in a .net 4.0 app and on build its fails... will play around a bit more and try get screen shots...

On Dec 2, 2009 12:19 PM, "Roy Chastain" <Roy <at> roychastain.org> wrote:

Well, actually, if you compile with NET_2_0 defined for use with .Net
2.0, it uses System.Net.Mail.

However, the ASPNetTraceAppender does reference the System.Web namespace
for access to the HttpContext class.

In both versions 2.0 and 4.0 of the framework, this class is in
System.Web.dll so there should be no difference from current
development.

----------------------------------------------------------------------
Roy Chastain

-----Original Message----- From: Ron Grabowski [mailto:rongrabowski <at> yahoo.com] Sent: Tuesday, D...

David Gerler | 2 Dec 2009 17:01
Picon

Using RollingFileAppender with style=Date.

How do I make it only keep a certain number of files when using the rollingstyle = date? I’ve looked on the website and have not been able to find an example of anything talking about it. This is what I have now:

 

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

                <file value="c:/log/register/gis/communications.txt" />

                <appendToFile value="true" />

                 <maxSizeRollBackups value="10" />

<rollingStyle value="Date" />

                 <datePattern value="yyyyMMdd-HHmm" />

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

                                <header value="[Header]&#xD;&#xA;" />

                                <footer value="[Footer]&#xD;&#xA;" />

                                <conversionPattern value="%date [%thread] %-5level %logger (%file:%line) - %message%newline" />

                </layout>

    </appender>

 

It doesn’t delete the files when I get to 10.

Petr Felzmann | 7 Dec 2009 19:12
Picon

Re: Using RollingFileAppender with style=Date.

Look at this
https://issues.apache.org/jira/browse/LOG4NET-27


Petr


2009/12/1 David Gerler <dgerler <at> gmail.com>

How do I make it only keep a certain number of files when using the rollingstyle = date? I’ve looked on the website and have not been able to find an example of anything talking about it. This is what I have now:

 

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

                <file value="c:/log/register/gis/communications.txt" />

                <appendToFile value="true" />

                 <maxSizeRollBackups value="10" />

<rollingStyle value="Date" />

                 <datePattern value="yyyyMMdd-HHmm" />

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

                                <header value="[Header]&#xD;&#xA;" />

                                <footer value="[Footer]&#xD;&#xA;" />

                                <conversionPattern value="%date [%thread] %-5level %logger (%file:%line) - %message%newline" />

                </layout>

    </appender>

 

It doesn’t delete the files when I get to 10.


Petite Escalope | 7 Dec 2009 20:12
Picon

Customized mail subject fo SmtpAppender

Hello,
I am using log4net for a web project and would like to make customized mail subjects my email appender. I already tried something like :

          <subject type="log4net.Util.PatternString" value="CovCake LOG INFO : %property{mailsubject}" />

 public static void MailInfo(string msg, string subjectDetails)
            {
                log4net.ThreadContext.Properties["mailsubject"] = subjectDetails;
                Log.Mail.Info(msg);
                log4net.ThreadContext.Properties.Clear();
            }

But it renders CovCake LOG INFO : (null).

Is there a way to customize mail subject natively (i mean without overriding existing classes or extending the SmtpAppender)?

Thank you very much. Sorry for my english.
   
Best regards


Pascal ROZE | 8 Dec 2009 09:42
Picon

Re: Customized mail subject fo SmtpAppender

Hi

Look at this: http://www.codeproject.com/KB/cs/log4net_SmtpAppender.aspx

Cheers

2009/12/7 Petite Escalope <miniscalope <at> gmail.com>
Hello,
I am using log4net for a web project and would like to make customized mail subjects my email appender. I already tried something like :

          <subject type="log4net.Util.PatternString" value="CovCake LOG INFO : %property{mailsubject}" />

 public static void MailInfo(string msg, string subjectDetails)
            {
                log4net.ThreadContext.Properties["mailsubject"] = subjectDetails;
                Log.Mail.Info(msg);
                log4net.ThreadContext.Properties.Clear();
            }

But it renders CovCake LOG INFO : (null).

Is there a way to customize mail subject natively (i mean without overriding existing classes or extending the SmtpAppender)?

Thank you very much. Sorry for my english.
   
Best regards



jclegall | 9 Dec 2009 02:53
Favicon

Partial logging with windows service


I have implemented log4net for a windows service, but I get a partial
logging.

Here is the code for my windows service:

private ILog _log;

protected override void OnStart(string[] args)
{
  GetLogger();
  _log.Info("Starting Services");
  _log.Info("Loading configuration file");
  //Additional code here...
  _log.Info("Service is running...");
}

protected override void OnStop()
{
  GetLogger();
  _log.Info("Stopping Services");
  //Additional code here
  _log.Info("Services Stopped");
}

 private void GetLogger()
 {
   if (_log == null)
   {
     _log = LogManager.GetLogger("MyWindowsServices");
   }
 }

My adapter is:
  <log4net>
    <!-- Levels  (from lowest to highest):  ALL | DEBUG | INFO | WARN |
ERROR | FATAL | OFF | -->
    <root>
      <level value="ALL" />
      <appender-ref ref="RollingFileAppender" />
    </root>

    <logger name="MyWindowsServices">
      <level value="ALL"/>
    </logger>

    <appender name="RollingFileAppender"
type="log4net.Appender.RollingFileAppender">
      <file value="My.Windows.Services.log" />
      <appendToFile value="true" />
      <rollingStyle value="Composite" />
      <datePattern value="yyyyMMdd" />
      <maxSizeRollBackups value="10" />
      <maximumFileSize value="3MB" />
      <staticLogFileName value="true" />
      <immediateFlush value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <header value="[Session Start]&#13;&#10;"/>
        <footer value="[Session End]&#13;&#10;"/>
        <conversionPattern value="%date [%thread] %-5level %logger
[%property{NDC}] - %message%newline" />
      </layout>
    </appender>
  </log4net>

The result of my log file contains only the log information from the Start
method of the windows service, but nothing for the stop:
[Session Start]
2009-12-09 10:39:13,986 [4] INFO  MyWindowsServices [(null)] - Starting
Services
2009-12-09 10:39:14,018 [4] INFO  MyWindowsServices [(null)] - Loading
configuration file
2009-12-09 10:39:14,033 [4] INFO  MyWindowsServices [(null)] - Service is
running...
[Session End]

What's wrong?

Thanks for your help!

--

-- 
View this message in context: http://old.nabble.com/Partial-logging-with-windows-service-tp26703955p26703955.html
Sent from the Log4net - Users mailing list archive at Nabble.com.


Gmane