Steve Hueners | 18 Aug 22:07 2014
Picon

AdoNetAppender on Azure SQL: Works then quits working

Last week I stepped thru the hoops required to configure a connection
string for my Azure SQL  db and confirmed that logging was working as
expected. Log messages were stored for several days, but at some
point, the logging ceased. I re-published the site (without changing
anything related to Log4Net) and logging was again active. Any other
similar reports? Anything non-optimal with my config?

much appreciated!

    <appender name="AdoNetAppender" type="log4net.Appender.AdoNetAppender">
      <bufferSize value="1" />
      <connectionType value="System.Data.SqlClient.SqlConnection,
System.Data,  Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />

      <connectionString
value="Server=tcp:myServer.database.windows.net,1433;Database=myDatabase;User
ID=myUser;Password=myPassword;Trusted_Connection=False;Encrypt=True;Connection
Timeout=30;" />
      <commandText value="INSERT INTO CULog
([Date],[Level],[Message],[Exception], Logger) VALUES ( <at> log_date,
 <at> log_level,  <at> message,  <at> exception,  <at> logger)" />
      <parameter>
        <parameterName value=" <at> log_date" />
        <dbType value="DateTime" />
        <layout type="log4net.Layout.RawTimeStampLayout" />
      </parameter>
      <parameter>
        <parameterName value=" <at> log_level" />
        <dbType value="String" />
(Continue reading)

Ananth Tatachar | 14 Aug 17:51 2014
Picon

Inconsistent results observed while using BufferingForwardAppender

I am working with log4net version : 1.2.12.0 .

 

I am getting inconsistent results , while using RollingFileAppender with BufferingForwardAppender.

My application is a multithreaded application. I spawned 5 threads Each will call the constructor of MyClass and SomeFunction once.

My application's sertup is as follows:

 

Web.config:

-------------------------------

 <appender name="RollingLocalFileAppender" type="log4net.Appender.RollingFileAppender">
      <
file type="log4net.Util.PatternString" value="C:\Logs\TFile.log" />
      <
rollingStyle value="Date" />
     <
datePattern value="yyyy-MM-dd" />
     <
maxSizeRollBackups value="10" />
      <
appendToFile value="true" />
     <
layout type="log4net.Layout.PatternLayout">
        <
conversionPattern value="%level %date{yyyy-MM-dd'T'HH:mm:ss.fffzzz} %property{hostname}  %property{guid} %message%newline" />
     </
layout>
    </
appender>
    <
appender name="BufferedFileAppender" type="log4net.Appender.BufferingForwardingAppender">
      <
bufferSize value="512" />
     <
evaluator type="log4net.Core.TimeEvaluator">

        <interval value="10" />
       
<!--Send buffered events immediately if 10 seconds pass-->
      </
evaluator>
     
<Fix value="0" />
    
<!--Buffering can have severe performance degradation if this is set to the default (ALL)-->
    </
appender>

 

 

Logging Class:

--------------------------

 

Class MyClass

{

public MyClass()

{

Log4net.ThreadContext.Properties["guid"] = Guid.NewGuid();

}

 

public void SomeFunction()

{

Ilog log = LogManager.GetLogger(typeof(MyClass));

Log.Info("my message");

}

 

}

 

 

Tfile.log(Result)

----------------------

Observed Results:

 

INFO 2014-08-14T10:47:36.659-04:00 ANANTHTATACHAR MyAudsDigest [LQR-Y8c71EmtWl7ZqItYoQ] my message

INFO 2014-08-14T10:47:36.659-04:00  ANANTHTATACHAR MyAudsDigest  [9hDzS-_Su0SrEoXZF_aGMw] my message

INFO 2014-08-14T10:47:36.729-04:00 ANANTHTATACHAR MyAudsDigest  [GsxT7aTfNEq1uIsqPYeZ5w]  my message

INFO 2014-08-14T10:47:36.789-04:00 ANANTHTATACHAR MyAudsDigest [9hDzS-_Su0SrEoXZF_aGMw] my message

INFO 2014-08-14T10:47:36.955-04:00 ANANTHTATACHAR MyAudsDigest  [9hDzS-_Su0SrEoXZF_aGMw] my message

 

 

 

Expected Results:

Unique guid in all the messages.

 

 

 

 

 

--------------------------------------------------------------------------------------------------------------------------------------

 

I understand that Fix value  NONE in log4net.Appender.BufferingForwardingAppender will not fix any volatile variables , but making it all results in all my guids in all the 5 messages becoming same.

 

Could anybody please tell me how to fix this issue?

Mohkam Singh Sawhney | 14 Aug 12:31 2014
Picon

RollingFileAppender overwriting previous log files on application restart

Hi,

I am using log4Net v1.2.13 in a .NET 4 C# project. I have setup a RollingFileAppender to roll on size. My aim is to keep appending to a log file and roll on size. I need to maintain all the previous log files. But I found that every time my application restarts all the log files after the 2nd log file that was generated in the previous run get overwritten.

For testing purposes I set the rollover size to 3KB. Below is the appender configuration.

<appender name="RollingAppender" type="log4net.Appender.RollingFileAppender">
<file value="logs22\myFile_d.log" />
<appendToFile value="true" />
<rollingStyle value="size" />
<staticLogFileName value="false" />
<maximumFileSize value="3KB" />
<countDirection value="1" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value = "%date %-5level [%logger] %message%newline%exception"/>
</layout>
</appender>

On first run of my application the appender rolls the log files on size. It created 3 log files myFile_d.log.0, myFile_d, myFile_d.log.2.  Each log file was around 5KB before getting rolled.

When I ran the application again, this time instead of creating a new log file myFile_d.log.3, Log4Net started overwriting the second log file that was generated earlier (that is myFile_d.log.1 was overwritten). It then proceeded to overwrite myFile_d.log.2.

I updated the config and included <maxSizeRollBackups value="-1" />. This time log files were rolled without any overwriting of existing files.

A similar scenario described in this issue tracker - LOG4NET-378. The bug has been closed with resolution fixed in v1.2.12.

I would appreciate it if somebody could confirm the following points
1. What is the default value of maxSizeRollBackups if it is not mentioned in the config file. I could not find this in documentation for this property.

2. For the scenario that I described is expected to include maxSizeRollBackups=-1 in the config file?



Thanks and Regards,

Mohkam Singh


Venkatasamy, Vanitha | 7 Aug 18:43 2014

Section or group name 'log4net' is already defined

I have a parent and child application. Log4net has been declared in both the web.config’s

 

Suddenly I started getting this below error in child application.

 

Exception information:

    Exception type: ConfigurationErrorsException

    Exception message: Section or group name 'log4net' is already defined. Updates to this may only occur at the configuration level where it is defined. (\web.config line 5)

 

 

If I remove the section from child web.config, some other error .

 

Any suggestion to look for

 

Thanks,

Vanitha Venkatasamy

XPAND Corporation.

 

 

 

This message contains Devin Group confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail in error and delete this e-mail from your system. E-mail transmissions cannot be guaranteed secure, error-free and information could be intercepted, corrupted, lost, destroyed, arrive late, incomplete, or contain viruses. The sender therefore does not accept liability for errors or omissions in the contents of this message which may arise as result of transmission. If verification is required please request hard-copy version
Shing Hing Man | 2 Aug 19:09 2014
Picon

How to specify a log output folder in RollingFileAppender

Hi,
  I am trying to set up llog4net  to use RollingFileAppender in  F# in VS 2013.

 <appender name="Roll" type="log4net.Appender.RollingFileAppender">
      <file      value="log_"/>
      <appendToFile value="true"/>
      <rollingStyle value="Date"/>
      <staticLogFileName value="false" />
      <datePattern value="yyyy_MM_dd.'txt'"/>
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger - %m%n" />
      </layout>
    </appender>

The above works. The log file log_2014_08_02.txt ends up  in {project}/bin/Debug directory.

However, I would like the log file to be in c:\ ,say.
I have tried
    <file      value="c:\log_"/>
and
  <file      value="${HOMEDRIVE}\log_"/>
but none of the above works.

How to set up <file> so that the output directory is in c:\  ?
Thanks in advance for your assistance!

Shing







Ananth Tatachar | 24 Jul 02:31 2014
Picon

Fwd: Log4net.ThreadContext.Properties Having stale data. How to resolve it?



---------- Forwarded message ----------
From: Ananth Tatachar <ananth.tatachar <at> gmail.com>
Date: Wed, Jul 23, 2014 at 8:24 PM
Subject: Log4net.ThreadContext.Properties Having stale data. How to resolve it?
To: log4net-user <at> logging.apache.org


I am using a RollingFileAppender , and my own custom layout. My application is multithreaded. Each thread will generate unique random data and is supposed to log it using log4net framework. However if I create multiple threads in quick succession I notice stale data in my logs , this goes away if each thread sleeps for 50 ms before logging. I am not able to figure out a solution to this issue or find its cause please do help me.

My logging function looks like this:


    log4net.ThreadContext.properties["randomGeneratedData"] = randomGeneratedData;
    private ILog myLog = 
           LogManager.GetLogger(typeof(LogTest));
    using (log4net.NDC.Push("ndcTest1"))
    {
        using (log4net.NDC.Push("ndcTest2"))
            {
                myLog.Info("myLogTest");
            }
    }





Result of logging:

       NDC = "ndcTest1 ndcTest2" , randomGeneratedData = rad1
       NDC = "ndcTest1 ndcTest2" , randomGeneratedData = rad2
       NDC = "", randomGeneratedData = rad2 

and so on ...


I tried to clear log4net.ThreadContext.Properties before filling it again , but it was of no use. Please help. 

Ananth Tatachar | 24 Jul 02:30 2014
Picon

Fwd: Log4net.ThreadContext.Properties Having stale data. How to resolve it?



---------- Forwarded message ----------
From: Ananth Tatachar <ananth.tatachar <at> gmail.com>
Date: Wed, Jul 23, 2014 at 8:24 PM
Subject: Log4net.ThreadContext.Properties Having stale data. How to resolve it?
To: log4net-user <at> logging.apache.org


I am using a RollingFileAppender , and my own custom layout. My application is multithreaded. Each thread will generate unique random data and is supposed to log it using log4net framework. However if I create multiple threads in quick succession I notice stale data in my logs , this goes away if each thread sleeps for 50 ms before logging. I am not able to figure out a solution to this issue or find its cause please do help me.

My logging function looks like this:


    log4net.ThreadContext.properties["randomGeneratedData"] = randomGeneratedData;
    private ILog myLog = 
           LogManager.GetLogger(typeof(LogTest));
    using (log4net.NDC.Push("ndcTest1"))
    {
        using (log4net.NDC.Push("ndcTest2"))
            {
                myLog.Info("myLogTest");
            }
    }





Result of logging:

       NDC = "ndcTest1 ndcTest2" , randomGeneratedData = rad1
       NDC = "ndcTest1 ndcTest2" , randomGeneratedData = rad2
       NDC = "", randomGeneratedData = rad2 

and so on ...


I tried to clear log4net.ThreadContext.Properties before filling it again , but it was of no use. Please help. 

Brian Broughton | 2 Jul 17:24 2014
Picon

AdoNetAppender - Wrong Values in Some Columns

Hello,

I have configured an AdoNetAppender in code (see below). I do end up with a 
record inserted into the table. The values inserted into the Date, Message 
and Exception columns are correct. However, the Thread, Level and Logger 
columns all contain the contents of "%message. If I use any of the other 
appenders (such as FileAppender), all values are logged correctly.

I’ve been searching for a couple of hours now and cannot find where anyone 
else has had this issue. Any help would be appreciated!

var dbAppender = new AdoNetAppender
            {
                Layout = layout,
                BufferSize = 1,
                ConnectionType = "System.Data.SqlClient.SqlConnection, 
System.Data, Version=1.0.3300.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089",
               ConnectionString = string.Format("data source='{0}';initial 
catalog={1};integrated security=false;persist security info=True;User ID=
{2};Password={3}", dbConfig.ServerName, dbConfig.DatabaseName, 
dbConfig.UserId, dbConfig.Password),
                CommandText = "INSERT INTO Log ([Date],[Thread],[Level],
[Logger],[Message],[Exception]) VALUES ( <at> log_date,  <at> thread,  <at> log_level, 
 <at> logger,  <at> message,  <at> exception)"          
            };

            dbAppender.AddParameter(new AdoNetAppenderParameter { 
ParameterName = " <at> log_date", DbType = DbType.DateTime, Layout = new 
RawTimeStampLayout() });
            dbAppender.AddParameter(new AdoNetAppenderParameter { 
ParameterName = " <at> thread", DbType = DbType.String, Size = 255, Layout = new 
Layout2RawLayoutAdapter(new PatternLayout { ConversionPattern = "%thread" }) 
});
            dbAppender.AddParameter(new AdoNetAppenderParameter { 
ParameterName = " <at> log_level", DbType = DbType.String, Size = 50, Layout = 
new Layout2RawLayoutAdapter(new PatternLayout { ConversionPattern = "%level" 
}) });
            dbAppender.AddParameter(new AdoNetAppenderParameter { 
ParameterName = " <at> logger", DbType = DbType.String, Size = 255, Layout = new 
Layout2RawLayoutAdapter(new PatternLayout { ConversionPattern = "%logger" }) 
});
            dbAppender.AddParameter(new AdoNetAppenderParameter { 
ParameterName = " <at> message", DbType = DbType.String, Size = 4000, Layout = 
new Layout2RawLayoutAdapter(new PatternLayout { ConversionPattern = 
"%message" }) });
            dbAppender.AddParameter(new AdoNetAppenderParameter { 
ParameterName = " <at> exception", DbType = DbType.String, Size = 2000, Layout = 
new Layout2RawLayoutAdapter(new ExceptionLayout()) });

            dbAppender.ActivateOptions();

Thank you,
Brian

Rob Richardson | 27 Jun 14:25 2014

Writing to two different log files

Greetings!

 

I am attempting to write to two different log files from inside one C# application.  I have defined two rolling file appenders.  I use the GetLogger() function to get references to each one, and I write to each in turn.  But both messages end up in the first file (cranesimulator_console.log), and the second file (cranesimulator_console_sim.log) is never created.

 

Here is my configuration file:

 

<?xml version="1.0" encoding="utf-8"?>

<log4net>

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

    <file value="CraneSimulator_Console.log" />

    <appendToFile value="true" />

    <maxSizeRollBackups value="90" />

    <rollingStyle value="Size" />

 

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

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

    </layout>

  </appender>

 

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

    <file value="CraneSimulator_Console_sim.log" />

    <appendToFile value="true" />

    <maxSizeRollBackups value="90" />

    <rollingStyle value="Size" />

 

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

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

    </layout>

  </appender>

</appender>

  <root>

     <level value="DEBUG" />

     <appender-ref ref="RollingFile" />

     <appender-ref ref="RollingFile_sim" />

  </root>

 

</log4net>

 

And here is the code that should be writing to the files:

 

            public CraneSimulator_Console(string xmlFileName)

            {

                  // m_simulator = new Simulator(xmlFileName, m_logger);

                  // string fullType = m_simulator.Database.GetType().AssemblyQualifiedName;

                  ILog m_logger = LogManager.GetLogger("RollingFile");

                  ILog simLogger = LogManager.GetLogger("RollingFile_sim");

                  System.IO.FileInfo logConfigFile = new System.IO.FileInfo(Environment.CurrentDirectory +

                                                                    "multiple_files.xml");

                  XmlConfigurator.ConfigureAndWatch(logConfigFile);

                  m_logger.Info("This is from cranesimulator_console.");

 

                  simLogger.Info("This should be in the sim logger.");

            }

 

Many thanks for your help!

 

tirath.g | 12 Jun 05:59 2014
Picon

set buffersize conditionally?

hi,

is it possible to set buffersize conditionally. i am trying to use log4net
for entire orgnaziation solution and writing info to a database table. can i
set different values of buffer size programically depending on some
condition( like request coming from application 1 to use buffer size = 100
others to use 1). thankyou.

--
View this message in context: http://apache-logging.6191.n7.nabble.com/set-buffersize-conditionally-tp48117.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

Alexey Polyakov | 1 Jun 16:49 2014

RE: log4net 1.2.13 performance issues (found the exact line that causes the problem)

Hello,

 

I have encountered a heavy drop in performance after migration from log4net 1.2.10 to 1.2.13. My research pointed out to the commit #1511303 and specifically to the line 1340:

                                             eventProperties[UserNameProperty] = UserName;

 

I attach the test harness I was using - without this line the logging is done in about 2 seconds, and after this line is added - it takes 24 seconds.

 

Can you please give any comment on what is going on? (is it safe to just remove this line and use patched version in production environment, or may be there is already a work in progress and a better solution)/

 

Best Regards,
Alexey Polyakov
Software Engineer


EPAM Systems
Ryazan office, Russia
GMT+3 (Standard) / GMT+3 (Daylight)

Office phone:       +7 (4912) 935-733, ext. 46229

Mobile phone:       +7 (910) 509-96-37

E-mail:         
        Alexey_Polyakov <at> epam.com

Skype:                 Aleksey__Polyakov (chat or call)

 

Attachment (smime.p7s): application/pkcs7-signature, 6197 bytes

Gmane