Jim Scott | 19 May 03:30 2015

RollingFIleAppender roll log files to sub folder

We  have a COM object logging object that our company uses to log in several applications that has a nice feature in which log files are rolled into a dated sub folder. Every now and then the netops crew asks why the applications that use log4net cannot do the same thing. Does this feature perhaps exist and I am just not aware of how to configure it? Anyone else have any interest in such a feature if not ?
Jim Scott | 19 May 03:28 2015

RollingFileAppender to zip file

Any plans to incorporate into log4net the ability to roll log files into a zip file? Our log files take up so much space and are highly compressible so would be really great to have such a feature built into log4net instead of having to write an external process.
Jim Scott | 19 May 03:21 2015

AdoNetAppender - Enhancement ?

This is a question I brought up back in 2011 and never ended up pursuing it 
far enough.

Scenario:
Currently have Log4Net setup to log all ERROR level events to a database by 
using the AdoNetAppender.

Issues:

1) Need combination of Buffering and time based triggering to write events 
to the database.

If we set the buffer size to 20 then we do not see anything logged to the 
database until the buffer fills up with 20 events which of course exactly 
what the buffer is designed to do. Since we want somewhat real-time logging 
to the database we end up setting the buffer size to 1 so that every event 
is written immediately. However what I would really like to see is a 
combination of buffer and timed based trigger events to write my events to 
the DB. If this was possible I would set my buffer to 20 events and set a 
timed based trigger to 30 seconds. Now my buffer will get written to the DB 
any time the timed event happens or 20 events are buffered.

2) Loss of database connectivity causes the AdoNetAppender to no longer 
write entries to the database.

Because the AdoNetAppender can cause the thread to hang for a long time if 
the database is unavailable we have set the ReconnectOnError to false. This 
unfortunately creates the issue I am facing in which if the SQL server is 
rebooted or service restarted the application quits talking to the database 
until the application is restarted.

I would love to see this feature extended to disable the buffer as it is now 
but then on every so many attempts or after a given time period if the 
buffer has events reattempt to write the entries to the DB and mark it as 
available again.

I am willing to do the work to make the enhancements but would love to see 
it make it back into log4net as I am sure others must need something like 
the above? Or perhaps I am missing some simple configuration options ?

Thanks
Jim Scott

William Bosacker (JIRA | 18 May 20:02 2015
Picon

[jira] [Commented] (LOG4NET-273) AdoNetAppender does not work if you dont copy System.Data.dll


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

William Bosacker commented on LOG4NET-273:
------------------------------------------

This is definitely an issue, if the System.Data.dll must be in the application folder.  I am not currently
certain if this is our issue as well, as our experience is that the logger sometimes works, but for the most
part does not.  Any DLL that is in the Global Assembly cache should not be in the application folder under any
circumstance.  If log4net is requiring that the DLL be in the application folder, then this is a log4net issue.

> AdoNetAppender does not work if you dont copy System.Data.dll
> -------------------------------------------------------------
>
>                 Key: LOG4NET-273
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-273
>             Project: Log4net
>          Issue Type: Wish
>    Affects Versions: 1.2.10
>         Environment: Windows 7, .Net 2.0
>            Reporter: Evald
>            Priority: Minor
>             Fix For: 1.2 Maintenance Release
>
>
> AdoNetAppender does not work if you dont copy System.Data.dll
> log4net writes at output this line: log4net:ERROR [AdoNetAppender] Failed to load connection type
[System.Data.SqlClient.SqlConnection, System.Data]
> if you copy the dll than it begin working.
> here it is my config:
>  <appender name="SQLAppender" type="log4net.Appender.AdoNetAppender">
>       <bufferSize value="1" />    
>       <connectionType value="System.Data.SqlClient.SqlConnection, System.Data" />
>       <connectionString value="Data Source=localhost;initial catalog=testlog4net;integrated
security=false;User ID=sa;Password=mypassword" />
>       <commandText value="INSERT INTO testlog4net.dbo.Log
([Date],[Thread],[LevelName],[Logger],[Message]) VALUES ( <at> log_date,  <at> thread,  <at> log_level,
 <at> logger,  <at> message)" />
>       <parameter>
>         <parameterName value=" <at> log_date" />
>         <dbType value="Datetime" />
>         <layout type="log4net.Layout.PatternLayout" value="%date{yyyy'-'MM'-'dd HH':'mm':'ss'.'fff}" />
>       </parameter>
>       <parameter>
>         <parameterName value=" <at> thread" />
>         <dbType value="String" />
>         <size value="255" />
>         <layout type="log4net.Layout.PatternLayout" value="%thread" />
>       </parameter>
>       <parameter>
>         <parameterName value=" <at> log_level" />
>         <dbType value="String" />
>         <size value="50" />
>         <layout type="log4net.Layout.PatternLayout" value="%level" />
>       </parameter>
>       <parameter>
>         <parameterName value=" <at> logger" />
>         <dbType value="String" />
>         <size value="255" />
>         <layout type="log4net.Layout.PatternLayout" value="%logger" />
>       </parameter>
>       <parameter>
>         <parameterName value=" <at> message" />
>         <dbType value="String" />
>         <size value="4000" />
>         <layout type="log4net.Layout.PatternLayout" value="%message" />
>       </parameter>
>         
>     </appender>
> Thank you
> Regards

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

Michel Émond | 12 May 21:01 2015

Rolling log file is overwritten when application is restarted

Hello,

This is the first time I contribute to an open source project, your assistance will be much appreciated.
I read your FAQ and I believe I'm doing things in the right manner. Please let me know otherwise.

While using version 1.2.13, I'm experiencing the issue described in this bug:
https://issues.apache.org/jira/browse/LOG4NET-378

In a nutshell: My app is running, rolling style is set to Composite, log files are piling up in the folder, all is good. Then I reset IIS, and restart my app. I would expect the rolling to continue on or after the last file. But instead, the rolling restarts at index 1 and overwrites the existing files.

The original bug fix addresses the issue in the InitializeFromOneFile() method.
However, the GetWildcardPatternForFile() method also needs the baseFileName to be adjusted with the datePattern so the proper files are searched.
I placed a file path fix in the DetermineCurSizeRollBackups() method, so it's then passed down to the two other methods and everyone gets happy.

Here's a calling stack sample:
DetermineCurSizeRollBackups()
|
+--GetExistingFiles()
|  +--GetWildcardPatternForFile()
|
+--InitializeRollBackups()
   +--InitializeFromOneFile()


You'll find attached to this email:
- the part of my web.config file that relates to log4net
- a patch containing my fix

Please let me know how good this fix is, and if it fits your quality standards.
Once we're settled, I could work on the unit tests, or let you deal with it at your convenience.

Thanks!

--
<at> import url(<a class="moz-txt-link-freetext" href="http://fonts.googleapis.com/css?family=Roboto+Slab:400,300,700">http://fonts.googleapis.com/css?family=Roboto+Slab:400,300,700); a, a:link, a:visited { color:#000000; }

Michel Émond
Programmer Analyst

T  1-514-272-0979 #240
T  1-800-972-0979 #240
www.innobec.com

Attachment (config.xml): text/xml, 1601 bytes
--- log4net-1.2.13\src\Appender\RollingFileAppender.cs	Sun Nov 17 14:44:38 2013 UTC
+++ log4net-1.2.13-fix\src\Appender\RollingFileAppender.cs	Tue May 12 17:53:22 2015 UTC
 <at>  <at>  -718,6 +718,10  <at>  <at> 
 			using(SecurityContext.Impersonate(this))
 			{
 				fullPath = System.IO.Path.GetFullPath(m_baseFileName);
+				if (m_rollDate && !m_staticLogFileName)
+				{
+					fullPath = CombinePath(fullPath, m_now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo));
+				}
 				fileName = System.IO.Path.GetFileName(fullPath);
 			}
 
 <at>  <at>  -901,19 +905,6  <at>  <at> 
 			}
             */
 	
-			// Only look for files in the current roll point
-			if (m_rollDate && !m_staticLogFileName)
-			{
-				string date = m_dateTime.Now.ToString(m_datePattern, System.Globalization.DateTimeFormatInfo.InvariantInfo);
-				string prefix = m_preserveLogFileNameExtension ?
Path.GetFileNameWithoutExtension(baseFile) + date : baseFile + date;
-				string suffix = m_preserveLogFileNameExtension ? Path.GetExtension(baseFile) : "";
-				if (!curFileName.StartsWith(prefix) || !curFileName.EndsWith(suffix))
-				{
-					LogLog.Debug(declaringType, "Ignoring file ["+curFileName+"] because it is from a different
date period");
-					return;
-				}
-			}
-            
 			try 
 			{
 				// Bump the counter up to the highest count seen so far
Stefan Bodewig (JIRA | 12 May 06:17 2015
Picon

[jira] [Resolved] (LOG4NET-458) LocalSyslogAppender does not support multiple identities


     [
https://issues.apache.org/jira/browse/LOG4NET-458?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Bodewig resolved LOG4NET-458.
------------------------------------
       Resolution: Pending Closed
    Fix Version/s: 1.3.0

Thanks, Christian!

patch committed as svn revision 1678858

> LocalSyslogAppender does not support multiple identities
> --------------------------------------------------------
>
>                 Key: LOG4NET-458
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-458
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 1.2.13
>            Reporter: Christian Becker
>             Fix For: 1.3.0
>
>         Attachments: localsyslog.patch
>
>
> With multiple LocalSyslogAppender where each one has a different identity, everything just gets logged
with the identity of the last Appender.
> In the example below, every log message has the identity of task_info_syslog, even the appender used is rts_syslog.
> I checked the code and this is a bug in LocalSyslogAppender.Append(). 
> The syslogtag is not part of the syslog() function call, but has to be done using openlog() and after a call
to openlog(), the identity set is used for all subsequent syslog() calls.
> A call to openlog() is only done once in ActivateOptions() and never again, this causes the observed
behavior, that the last instance of LocalSyslogAppender wins. 
> A possible fix for this is to add a call to openlog() in Append() before calling syslog(), like:
> {code}
> diff --git a/LocalSyslogAppender.cs b/LocalSyslogAppender.cs
> --- a/LocalSyslogAppender.cs
> +++ b/LocalSyslogAppender.cs
>  <at>  <at>  -387,6 +387,8  <at>  <at>  namespace log4net.Appender
>              int priority = GeneratePriority(m_facility, GetSeverity(loggingEvent.Level));
>              string message = RenderLoggingEvent(loggingEvent);
> +            // Call libc openlog() first to ensure correct identity and facility is set
> +            openlog(m_handleToIdentity, 1, m_facility);
>              // Call the local libc syslog method
>              // The second argument is a printf style format string
>              syslog(priority, "%s", message);
> {code}
> Here is our config for reference:
> {code}
> [...]
> <appender name="rts_syslog" type="log4net.Appender.LocalSyslogAppender">
>   <facility value="User" />
>   <identity type="log4net.Util.PatternString" value="foobar/dev/dev1/rts" />
>   <layout type="log4net.Layout.PatternLayout">
>     <conversionPattern value="%date{yyyy-MM-dd HH:mm:ss}, %level, %message%newline" />
>   </layout>
> </appender>
> [...]
> <appender name="task_info_syslog" type="log4net.Appender.LocalSyslogAppender">
>   <facility value="User" />
>   <identity type="log4net.Util.PatternString" value="foobar/dev/dev1/task-info" />
>   <layout type="log4net.Layout.PatternLayout">
>     <conversionPattern value="%date{yyyy-MM-dd HH:mm:ss}, %level, %message%newline" />
>   </layout>
> </appender>
> [...]
> {code}

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

Christian Becker (JIRA | 11 May 16:38 2015
Picon

[jira] [Commented] (LOG4NET-458) LocalSyslogAppender does not support multiple identities


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

Christian Becker commented on LOG4NET-458:
------------------------------------------

Hi Stefan,

thank you for the patch.

We've implemented it on May 30th and there are no issues so far.

Cheers,
Christian

> LocalSyslogAppender does not support multiple identities
> --------------------------------------------------------
>
>                 Key: LOG4NET-458
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-458
>             Project: Log4net
>          Issue Type: Bug
>          Components: Appenders
>    Affects Versions: 1.2.13
>            Reporter: Christian Becker
>         Attachments: localsyslog.patch
>
>
> With multiple LocalSyslogAppender where each one has a different identity, everything just gets logged
with the identity of the last Appender.
> In the example below, every log message has the identity of task_info_syslog, even the appender used is rts_syslog.
> I checked the code and this is a bug in LocalSyslogAppender.Append(). 
> The syslogtag is not part of the syslog() function call, but has to be done using openlog() and after a call
to openlog(), the identity set is used for all subsequent syslog() calls.
> A call to openlog() is only done once in ActivateOptions() and never again, this causes the observed
behavior, that the last instance of LocalSyslogAppender wins. 
> A possible fix for this is to add a call to openlog() in Append() before calling syslog(), like:
> {code}
> diff --git a/LocalSyslogAppender.cs b/LocalSyslogAppender.cs
> --- a/LocalSyslogAppender.cs
> +++ b/LocalSyslogAppender.cs
>  <at>  <at>  -387,6 +387,8  <at>  <at>  namespace log4net.Appender
>              int priority = GeneratePriority(m_facility, GetSeverity(loggingEvent.Level));
>              string message = RenderLoggingEvent(loggingEvent);
> +            // Call libc openlog() first to ensure correct identity and facility is set
> +            openlog(m_handleToIdentity, 1, m_facility);
>              // Call the local libc syslog method
>              // The second argument is a printf style format string
>              syslog(priority, "%s", message);
> {code}
> Here is our config for reference:
> {code}
> [...]
> <appender name="rts_syslog" type="log4net.Appender.LocalSyslogAppender">
>   <facility value="User" />
>   <identity type="log4net.Util.PatternString" value="foobar/dev/dev1/rts" />
>   <layout type="log4net.Layout.PatternLayout">
>     <conversionPattern value="%date{yyyy-MM-dd HH:mm:ss}, %level, %message%newline" />
>   </layout>
> </appender>
> [...]
> <appender name="task_info_syslog" type="log4net.Appender.LocalSyslogAppender">
>   <facility value="User" />
>   <identity type="log4net.Util.PatternString" value="foobar/dev/dev1/task-info" />
>   <layout type="log4net.Layout.PatternLayout">
>     <conversionPattern value="%date{yyyy-MM-dd HH:mm:ss}, %level, %message%newline" />
>   </layout>
> </appender>
> [...]
> {code}

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

Daniel Hernandez (JIRA | 28 Apr 17:18 2015
Picon

[jira] [Commented] (LOG4NET-463) No Log File Is Created When Using .NET Framework 4.5.1


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

Daniel Hernandez commented on LOG4NET-463:
------------------------------------------

The issue was fixed it with the following code in global.asax.cs

 In the Application_Start() method point to the location of the log4net file like this:

 System.IO.FileInfo log4netFI = new System.IO.FileInfo(HttpRuntime.AppDomainAppPath+"\\log4net.config");
 log4net.Config.XmlConfigurator.ConfigureAndWatch(log4netFI);

> No Log File Is Created When Using .NET Framework 4.5.1
> ------------------------------------------------------
>
>                 Key: LOG4NET-463
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-463
>             Project: Log4net
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 1.2.13
>         Environment: Windows 7 Enterprise 64 bit OS
> .NET Framework 4.5.1
>            Reporter: Daniel Hernandez
>            Assignee: Dominik Psenner
>
> I read all about the 2 following bug reports:
> - LOG4NET - 451
> - LOG4NET - 452
> I still cannot get log4net to create/write to a log file.  My web forms C# app compiles fine in Visual Studio
2013.  I don't get any errors when I run my app, I just don't see the log file get created.
> In the NuGet Manager I installed log4net[1.2.13] but I noticed that on the right hand side where the
description of the package resides, I see:
> Created by: Apache Software Foundation
> Id: log4net
> Version: 2.0.3
> so is 1.2.13 the version of the NuGet package not the version of log4net?

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

Dominik Psenner (JIRA | 27 Apr 13:40 2015
Picon

[jira] [Closed] (LOG4NET-463) No Log File Is Created When Using .NET Framework 4.5.1


     [
https://issues.apache.org/jira/browse/LOG4NET-463?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dominik Psenner closed LOG4NET-463.
-----------------------------------
    Resolution: Invalid
      Assignee: Dominik Psenner

This will most likely not related to the .net version but rather a configuration or privilege issue. Please
see the faq, there you will find valuable information also about the nuget packes.

http://logging.apache.org/log4net/log4net-1.2.12/release/faq.html

Feel free to contact the mailing list and ask for help there. If you do actually find a reproducable issue
with log4net you might want to reopen the issue, but please do not forget to include information on how the
issue can be reproduces as detailed as possible.

> No Log File Is Created When Using .NET Framework 4.5.1
> ------------------------------------------------------
>
>                 Key: LOG4NET-463
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-463
>             Project: Log4net
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 1.2.13
>         Environment: Windows 7 Enterprise 64 bit OS
> .NET Framework 4.5.1
>            Reporter: Daniel Hernandez
>            Assignee: Dominik Psenner
>
> I read all about the 2 following bug reports:
> - LOG4NET - 451
> - LOG4NET - 452
> I still cannot get log4net to create/write to a log file.  My web forms C# app compiles fine in Visual Studio
2013.  I don't get any errors when I run my app, I just don't see the log file get created.
> In the NuGet Manager I installed log4net[1.2.13] but I noticed that on the right hand side where the
description of the package resides, I see:
> Created by: Apache Software Foundation
> Id: log4net
> Version: 2.0.3
> so is 1.2.13 the version of the NuGet package not the version of log4net?

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

Daniel Hernandez (JIRA | 25 Apr 00:10 2015
Picon

[jira] [Created] (LOG4NET-463) No Log File Is Created When Using .NET Framework 4.5.1

Daniel Hernandez created LOG4NET-463:
----------------------------------------

             Summary: No Log File Is Created When Using .NET Framework 4.5.1
                 Key: LOG4NET-463
                 URL: https://issues.apache.org/jira/browse/LOG4NET-463
             Project: Log4net
          Issue Type: Bug
          Components: Other
    Affects Versions: 1.2.13
         Environment: Windows 7 Enterprise 64 bit OS
.NET Framework 4.5.1
            Reporter: Daniel Hernandez

I read all about the 2 following bug reports:
- LOG4NET - 451
- LOG4NET - 452

I still cannot get log4net to create/write to a log file.  My web forms C# app compiles fine in Visual Studio
2013.  I don't get any errors when I run my app, I just don't see the log file get created.

In the NuGet Manager I installed log4net[1.2.13] but I noticed that on the right hand side where the
description of the package resides, I see:
Created by: Apache Software Foundation
Id: log4net
Version: 2.0.3

so is 1.2.13 the version of the NuGet package not the version of log4net?

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

Stefan Bodewig (JIRA | 23 Apr 21:07 2015
Picon

[jira] [Resolved] (LOG4NET-462) ReadOnlyPropertiesDictionary not thread safe


     [
https://issues.apache.org/jira/browse/LOG4NET-462?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Bodewig resolved LOG4NET-462.
------------------------------------
       Resolution: Fixed
    Fix Version/s: 1.3.0

Well, the inheritance hierarchy is pretty strange, PropertiesDictionary is a subclass of
ReadOnlyPropertiesDictionary - and happily modifies the internal hashtable.  To be honest I don't
understand why it looks the way it does, in particualr since PropertiesDictionary  reimplements most of
the methods anyway.

I think the problem should be fixed with svn revision 1675705 but for 1.3 we may as well rethink the
inheritance hierarchy anyway.

> ReadOnlyPropertiesDictionary not thread safe
> --------------------------------------------
>
>                 Key: LOG4NET-462
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-462
>             Project: Log4net
>          Issue Type: Bug
>    Affects Versions: 1.2.13
>            Reporter: Tom Tutko
>            Priority: Blocker
>              Labels: thread-safety
>             Fix For: 1.3.0
>
>
> I have an application that runs as a windows service and spins up multiple AppDomains, each with their own
loggers. I will often run into an issue where log4net appears to be causing one or more of the spun up
AppDomains to not function properly. The relevant stack trace looks as follows:
> System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
>   at System.Collections.Hashtable.HashtableEnumerator.MoveNext()
>   at log4net.Util.ReadOnlyPropertiesDictionary.GetObjectData(Serialization info,
StreamingContext context)
>   at System.Runtime.Serialization.ObjectCloneHelper.GetObjectData(Object serObj, String&amp;
typeName, String&amp; assemName, String[]&amp; fieldNames, Object[]&amp; fieldValues)
> I have not been able to find the specific conditions to reproduce this but it happens often enough to be a
huge problem. Looking at the log4net source, the ReadOnlyPropertiesDictionary.GetObjectData()
method does a foreach over the InnerHashTable collection but there is nothing to stop that collection
from being modified outside of that loop which is leading to the exception. I am not sure where in my code I
would be doing anything that modified that collection indirectly but I do know that I push several things
on and off of the LogicalThreadContext.

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


Gmane