Chris Jerdonek | 4 Mar 05:20 2008

rollingfileappender - repetition of file name suffix

Hi,

I've searched around the documentation and on the web but couldn't find
reference to this behavior (though the recent thread called "log4net and
IIS problems" seems indirectly related.) 

I'm using a RollingFileAppender with a MinimalLock and simple date
pattern for the file name.  When I deploy my application, I get several
files of the following form in my log directory (at bottom is the
configuration):

log2008-03.0
log2008-03.02008-03.0
log2008-03.02008-03.02008-03.0

Is this by design?  My understanding was that the MinimalLock permits
writes from multiple processes (though more slowly).

I'm using the appender for an ASP.NET application in an app pool with
more than one instance of the application running, and that undergoes
worker process recycling periodically.

I also understand that this is not the ideal scenario for a
RollingFileAppender, but I'm just looking for something quick and wanted
to understand the behavior above a bit better.

Okay, thanks in advance for your help, and thanks also for your work in
keeping this project going.

--Chris
(Continue reading)

Ron Grabowski | 4 Mar 18:02 2008
Picon

Re: rollingfileappender - repetition of file name suffix

Having a log file named:

 log2008-03.02008-03.02008-03.02008-03.02008-03.02008-03.02008-03.0 

is not by design. Using multiple processes, MinimalLocks, and RollingFileAppender is probably not going
to work out well for you. There's no way for the RollingFileAppender instances in each process to
communicate who should initiate the rolling. I'd suggest using a database. You might have better luck
using the MutextLock class that was posted to the list a couple weeks ago. That's a more effecient way of
allowing multiple processes to write to the same file without having to always open and close the file each message.

----- Original Message ----
From: Chris Jerdonek <jerdonek <at> granicus.com>
To: log4net-user <at> logging.apache.org
Sent: Monday, March 3, 2008 11:20:31 PM
Subject: rollingfileappender - repetition of file name suffix

Hi,

I've searched around the documentation and on the web but couldn't find
reference to this behavior (though the recent thread called "log4net and
IIS problems" seems indirectly related.) 

I'm using a RollingFileAppender with a MinimalLock and simple date
pattern for the file name.  When I deploy my application, I get several
files of the following form in my log directory (at bottom is the
configuration):

log2008-03.0
log2008-03.02008-03.0
log2008-03.02008-03.02008-03.0
(Continue reading)

Parrish, Ken | 7 Mar 17:44 2008

Reusable layouts ...

Is there a way in a log4net configuration file to specify a layout pattern and then reference that pattern from multiple appenders.  In the following config file snippet, the same layout specification is used by two different appenders.  Is there a way to specify the pattern just once and reference that patter by each of the two appenders?

 

Thanks,

 

Ken Parrish

Gomez, Inc.

 

<!-- Standard rolling file appender -->
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
     
<file value="RollingFile.log" />
     
<appendToFile value="true" />
     
<rollingStyle value="Size" />
     
<maxSizeRollBackups value="10" />
     
<maximumFileSize value="10MB" />
     
<layout type="log4net.Layout.PatternLayout">
           
<param name="ConversionPattern" value="%date{yyyy-MM-dd HH:mm:ss.fff} [%t] %-5level %logger - %message%newline%exception" />
     
</layout>
</appender>

<!-- Windows Application Event Log appender -->
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
     
<applicationName value="MyApplication" />
     
<layout type="log4net.Layout.PatternLayout">
           
<param name="ConversionPattern" value="%date{yyyy-MM-dd HH:mm:ss.fff} [%t] %-5level %logger - %message%newline%exception" />
     
</layout>
</appender>


 

Ron Grabowski | 9 Mar 18:42 2008
Picon

Re: Reusable layouts ...

You could make a custom PatternLayout class:

 <layout type="Company.Log4NetIntegration.DateThreadLevelLoggerLayout, Company.Log4NetIntegration">

You could also add a property to the repository then write a layout that looks for that property by default:

 <!-- looks for the property "defaultConversionPattern" in the repositories properties -->
 <layout type="Company.Log4netIntegration.RepLayout, Company.Log4netIntegration" />

----- Original Message ----
From: "Parrish, Ken" <KParrish <at> gomez.com>
To: log4net-user <at> logging.apache.org
Sent: Friday, March 7, 2008 11:44:26 AM
Subject: Reusable layouts ...

<!-- _filtered {font-family:Fixedsys;panose-1:0 0 0 0 0 0 0 0 0 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0in;margin-bottom:.0001pt;font-size:12.0pt;font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue;text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {color:purple;text-decoration:underline;} span.EmailStyle17 {font-family:Arial;color:windowtext;} _filtered {margin:1.0in 1.25in 1.0in 1.25in;} div.Section1 {} -->

Is there a way in a log4net configuration file to specify a layout pattern and then reference that pattern from multiple appenders.  In the following config file snippet, the same layout specification is used by two different appenders.  Is there a way to specify the pattern just once and reference that patter by each of the two appenders?

 

Thanks,

 

Ken Parrish

Gomez, Inc.

 

<!-- Standard rolling file appender -->
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
     
<file value="RollingFile.log" />
     
<appendToFile value="true" />
     
<rollingStyle value="Size" />
     
<maxSizeRollBackups value="10" />
     
<maximumFileSize value="10MB" />
     
<layout type="log4net.Layout.PatternLayout">
           
<param name="ConversionPattern" value="%date{yyyy-MM-dd HH:mm:ss.fff} [%t] %-5level %logger - %message%newline%exception" />
     
</layout>
</appender>

<!-- Windows Application Event Log appender -->
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
     
<applicationName value="MyApplication" />
     
<layout type="log4net.Layout.PatternLayout">
           
<param name="ConversionPattern" value="%date{yyyy-MM-dd HH:mm:ss.fff} [%t] %-5level %logger - %message%newline%exception" />
     
</layout>
</appender>


 


Paul_uniquename | 10 Mar 03:05 2008
Picon

Usage guide for Vista?


I can't seem to write a log file anywhere on Vista. Is there any guide for
using log4net on vista?

I thought this setting in log4net.config was going to save me, but it
doesn't seem to write a file.

<file value="${ALLUSERSPROFILE}\Application Data\MyStuff\logs\MyLog.log" />

--

-- 
View this message in context: http://www.nabble.com/Usage-guide-for-Vista--tp15949615p15949615.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

Paul_uniquename | 10 Mar 03:16 2008
Picon

Re: Usage guide for Vista?


Let me put this another way.

Has anyone gotten log4net to write a log file on Vista? If so, how did you
do it?

--

-- 
View this message in context: http://www.nabble.com/Usage-guide-for-Vista--tp15949615p15949674.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

Ron Grabowski | 10 Mar 03:24 2008
Picon

Re: Usage guide for Vista?

Log4net uses a standard FileStream object internally:

 new FileStream(filename, fileOpenMode, FileAccess.Write, FileShare.Read)

Assuming you can get that to work (in a ConsoleApplication or some other type of simple app) you can most
likely get log4net working.

----- Original Message ----
From: Paul_uniquename <waveangle <at> yahoo.com>
To: log4net-user <at> logging.apache.org
Sent: Sunday, March 9, 2008 10:16:54 PM
Subject: Re: Usage guide for Vista?

Let me put this another way.

Has anyone gotten log4net to write a log file on Vista? If so, how did you
do it?

--

-- 
View this message in context: http://www.nabble.com/Usage-guide-for-Vista--tp15949615p15949674.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

Paul_uniquename | 10 Mar 03:52 2008
Picon

Re: Usage guide for Vista?


My log4net.config file uses this line. I thought it was going to work.

<file value="${ALLUSERSPROFILE}\Application Data\MyStuff\logs\MyLog.log" />

I need an environment variable here that _always_ works on xp and vista if
admin or non-admin.

Or, how can I keep using the log4net.config file, but programatically change
the path of the log file at runtime? That might work but I couldn't figure
that out either.

--

-- 
View this message in context: http://www.nabble.com/Usage-guide-for-Vista--tp15949615p15949950.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

Paul_uniquename | 10 Mar 04:37 2008
Picon

Re: Usage guide for Vista?


Nevermind this thread, I got it working now.

--

-- 
View this message in context: http://www.nabble.com/Usage-guide-for-Vista--tp15949615p15950335.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

Simon E. Devlin | 10 Mar 04:51 2008

RE: Usage guide for Vista?

In case someone else runs into a similar problem, what was the answer?

Cheers
________________________________________
From: Paul_uniquename [waveangle <at> yahoo.com]
Sent: Monday, 10 March 2008 2:37 PM
To: log4net-user <at> logging.apache.org
Subject: Re: Usage guide for Vista?

Nevermind this thread, I got it working now.

--
View this message in context: http://www.nabble.com/Usage-guide-for-Vista--tp15949615p15950335.html
Sent from the Log4net - Users mailing list archive at Nabble.com.


Gmane