Daniel Ingalla | 19 Apr 19:57 2014
Picon

Output in Ubuntu Linux

All,

Anyone have any experience logging on a .net mono app running on Ubuntu? I have a console appender setup on the root logger. This works on Windows without issue, but I see no output in Linux. My .Net app is started on the command line.

Probably a shell thing eh?

Regards,
D
Venkatasamy, Vanitha | 18 Apr 16:35 2014

log4Net version 1.2.11.0 / product version

Hi,

 

I am using the log4net to handle the error logging in my application .  Nothing changed ,but all of sudden I am getting the below message added on top my custom error page .

 

 

 

Any idea.?

 

 

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
Tom Williams | 21 Feb 16:48 2014

Help needed with debugging AdoNetAppender

We’re using log4net 1.2.11 to log to a SQL Server database from an internal Windows service.   For the most part, log4net is working very well except for when SQL Server terminates the inactive log4net connection overnight.

 

I have the “reconnectonerror” property set to “true” in the log4net.config file but the database connection doesn’t appear to get re-established.

 

Anyway, I found how to enable log4net internal debugging and when I enable it, I get log messages but nothing from the AdoNetAppender.  I can see the AdoNetAppender being setup, but when I successfully log to the database using the AdoNetAppender, I get nothing in the debug output.  I also use a RollingFileAppender to log messages generated by our Windows service and I can see debug messages showing the log file getting rolled, per our RollingFileAppender configuration settings.

 

So, my questions are:

 

1)       How can I get internal debug output from the AdoNetAppender?

2)      What is the best way to debug failed attempts to reconnect to the SQL Server database?

 

We’re connecting to SQL Server 2008 and when things do work, log messages get logged in the database as desired.

 

Here is a snipet from our app.config file, which enables internal log4net debugging:

 

--------------  START  -----------------

 

<appSettings>

    …..

   <add key=”log4net.Internal.Debug” value=”true” />

</appSettings>

<system.diagnostics>

  <trace autoflush=”true”>

    <listeners>

       <add name=”textWriterTraceListener” type=”System.Diagnostics.TextWriterTraceListener” initializeData=”log4net-debug.log” />

    </listeners>

  </trace>

</system.diagnostics>

 

--------------  END --------------------

 

That creates a “log4net-debug.log” file that contains lots of info, once the Windows service has been running for a while.

 

Here is a snipet from our log4net.config file, which defines our appenders:

 

--------------  START  ------------------

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

<configuration>

<log4net>

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

     <file value=”service.log” />

    <appendToFile value=”true” />

    <maximumFileSize value=”100kb” />

    <maxSizeRollBackups value=”2” />

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

          <conversionPattern value=”%date [%thread] %-5level %a %logger = %message%newline” />

    </layout>

  </appender>

 

  <appender name=”ADONetAppender” type=”log4net.Appender.ADONetAppender”>

     <bufferSize value=”1” />

     <connectionType value=”System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken={some string}” />

     <connectionString value=”{connection string for database connection}” />

     <commandText value=”{SQL INSERT statement to log data}” />

     <reconnectonerror value=”true” />

 

     <parameter>

         <parameterName value=” <at> application” />

        <dbType value=”String” />

        <size value=”100” />

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

           <conversionPattern value=”%appdomain” />

        </layout>

     </parameter>

 

(more parameters are defined similar to the above parameter)

  </appender>

 

  <root>

      <level value=”DEBUG” />

      <appender-ref ref=”RollingFile” />

  </root>

 

  <logger name=”DBLog”>

     <appender-ref ref=”ADONetAppender” />

  </logger>

</log4net>

</configuration>

--------------- END  --------------------

 

So, with the above settings, when I first start the Windows service, the log4net-debug.log file shows the creation of the appenders and it will eventually show the rolling of the log file.  I never see any messages from the ADONetAppender showing it logging messages to the database. 

 

Thanks!

 

Tom

The information contained in this electronic mail message is confidential information intended only for the use of the individual or entity named above. The information herein may also be protected by the Electronic Communications Privacy Act, 18 USC Sections 2510-2521. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify us by e-mail and delete the original message. In addition, to ensure compliance with requirements imposed by the IRS, we inform you that any U.S. tax advice contained in this communication (including any attachments) is not intended or written to be used, and cannot be used, for the purpose of (a) avoiding penalties under the Internal Revenue Code, or (b) promoting, marketing or recommending to another party any matters addressed in this communication. Thank you.

moonstone | 17 Feb 20:58 2014
Picon

how to keep 3 days of logs

I need to keep 3 days of logging information from my application, which runs
once per day.  For example, if I start with 3 days worth of logging
information retained:
CustomerDataTransfer.2014-02-15.txt
CustomerDataTransfer.2014-02-14.txt
CustomerDataTransfer.2014-02-13.txt

When I run the application on Feb 17, I'd like to have these 3 files
retained
CustomerDataTransfer.2014-02-17.txt
CustomerDataTransfer.2014-02-15.txt
CustomerDataTransfer.2014-02-14.txt

Is it possible to configure log4net this way?

Here's the configuration information I currently use.

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

      
      <datePattern value="'.'yyyy-MM-dd'.txt'" />

      

      

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

        

      </layout>
    </appender>

--
View this message in context: http://apache-logging.6191.n7.nabble.com/how-to-keep-3-days-of-logs-tp44594.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

xaruman | 10 Feb 17:07 2014
Picon

Log4Net log into a remote C# App

Hi

I've been looking for a solution during several days but I've not found
anything. The issue is that I have an application which is saving logs by
log4net (a log file) and I need to "capture" this logs into a remote
application. I thought about mapping the log file into my remote
application, but I think that maybe there is a solution to my problem using
directly log4net functionality. 

Is it possible to "subscribe" remotely to a log4net logging? I mean, what I
need is that when A application prints a log into its log file, my B
application in a different computer advices this and display the information
in a win form. Remote append? a Server/client append? I have no idea about
how to fix this problem.

Thanks in advance for your help. Hope having been clear enough.

--
View this message in context: http://apache-logging.6191.n7.nabble.com/Log4Net-log-into-a-remote-C-App-tp44380.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

Trent Cioran | 4 Feb 23:17 2014
Picon

Logging repositories

Hello All,

I have an advanced scenario for logging:

1) - I have an application which logs to default repository
2) - A manager thread that acts as a coordinator for the work to be done, this component should log to its own log file
3) - A processing thread that performs the actual work, this component will process X number of items so I want to log the component's activity to its own log so it is easier to troubleshoot in case of error and not mix with other processing threads output.
4) - An error log which should generate the detail for a specific processing item error 

Currently I have two appenders configured with filters so one logs to file DEBUG and INFO and the other logs only ERROR.

I am using a pattern string to specify the name of the log file like this: Processor_Mbx_%property{mbxId}_Seq_%property{seq}_%date{yyyyMMdd}.txt

I am using repositories in order to keep them separated and also to specify different configuration for each repository (for example manager thread only requires ,bxId and seq variables for the log file name while the item error requires these two and a third itemId. I am configuring my repositories using 

                var repository = LogManager.CreateRepository(repositoryName);

                XmlConfigurator.ConfigureAndWatch(repository, configFileInfo); // See sample at the bottom



These properties are set using the ThreadContext so each thread do not collide with the others. Log4net is generating the files as expected everything nice here, but the log goes to the first file that it created, for example, it creates files 

Processor_Mbx_1012_Seq_1_20140204.txt <--- logs are sent to this file
Processor_Mbx_1013_Seq_1_20140204.txt


I already tried using ThreadContext.Properties and ThreadContext.Stack but I get the same behaviour


Hope someone has an idea of why I am getting this behaviour and what I need to do to get the result I want.


Thanks in advance,
TrentCioran


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

Sample configuration file: 


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

<log4net>

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

    <file type="log4net.Util.PatternString" value="C:\Logs\InfoLogs\Processor_Mbx_%property{mbxId}_%date{yyyyMMdd}.txt"/>

    <staticLogFileName value="true"/>

    <param name="appendToFile" value="true"/>

    <param name="maximumFileSize" value="10MB"/>

    <param name="maxSizeRollBackups" value="1000"/>

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

      <conversionPattern value="%date|[%thread]|%-5level|%logger|%property{NDC}|%message%newline"/>

    </layout>

    <filter type="log4net.Filter.LevelMatchFilter">

      <levelToMatch value="DEBUG"/>

    </filter>

    <filter type="log4net.Filter.DenyAllFilter"/>

  </appender>

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

    <threshold value="ERROR"/>

    <file type="log4net.Util.PatternString" value="C:\Logs\ErrorLogs\Processor_Mbx_%property{mbxId}_%date{yyyyMMdd}.txt"/>

    <staticLogFileName value="true"/>

    <param name="maximumFileSize" value="10MB"/>

    <param name="maxSizeRollBackups" value="1000"/>

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

      <conversionPattern value="%date|[%thread]|%-5level|%logger|%property{NDC}|%message%newline"/>

    </layout>

    <filter type="log4net.Filter.LevelMatchFilter">

      <levelToMatch value="ERROR"/>

    </filter>

    <filter type="log4net.Filter.DenyAllFilter"/>

  </appender>

  <root>

    <level value="DEBUG" />

    <appender-ref ref="errorAppender" />

    <appender-ref ref="infoAppender" />

  </root>

</log4net>




Picon

log4net filling memory in prod

Is there a way using log4net to limit the memory usage for logs?  The thread and private byte could goes out the window.  Also if trying to log to a path that the system doesn’t have rights it holds onto the events.  Is there a setting for simply dropping log entries that can’t be saved?

 

Thank you!

Douglas Neary | 14 Jan 23:36 2014

log4net rolling file appender losing log files during roll over

All:

 

Under heavy strain, I am seeing log4net lose log files during roll over.   I filed a bug yesterday (https://issues.apache.org/jira/browse/LOG4NET-416), and I wanted to offer my help (and hardware) to help track it down.  I attached the internal log4net log to the ticket.

 

The hardware we are using is pretty high end (http://www8.hp.com/us/en/products/proliant-servers/product-detail.html?oid=4231377#!tab=features).    We are using this beast as a combined image processor and web server, running IIS 7.5 on Windows Server 2008 R2. 

 

For every transaction processed, a line is written to log4net.   On average, we are probably doing around 7 transactions per second.  This works fine for a while, until it doesn’t.   Then it starts losing log files during rollover.

 

Given all the value we have gotten out of log4net, my company is willing to donate some of my time and some time on that DL980 to test out the fixes…

 

Is there anyone who can give me a push in the right direction?

 

Thanks,
Doug

Picon

Multiple processes logging to single file - unexplained error message

I am using log4net 1.2.10. It has been stated on this forum that from 1.2.9
onwards, different file locking schemas are available. I have configured
log4net as per examples given to use a non-default method (minimal-locking
or interprocess locking) but the immediate effect is the following error
message:

log4net:ERROR XmlHierarchyConfigurator: Cannot find Property [lockingModel]
to set object on
[log4net.Repository.Hierarchy.DefaultLoggerFactory+LoggerImpl]
log4net:ERROR [RollingFileAppender] Unable to acquire lock on file
C:\Program Files (x86)\Autoscribe\Matrix Gemini LIMS\Exe\log\Trace.log. The
process cannot access the file 'C:\Program Files (x86)\Autoscribe\Matrix
Gemini LIMS\Exe\log\Trace.log' because it is being used by another process.

My log4net.config file is:

		<logger name="Matrix.Trace">
			  
			<level value="OFF" />
			     <lockingModel type="log4net.Appender.FileAppender+InterProcessLock"
/>
			<appender-ref ref="RollingFileAppenderTRACE" />
		</logger>

		<appender name="RollingFileAppenderTRACE"
type="log4net.Appender.RollingFileAppender">
			<file value=".\log\Trace.log" />
			<layout type="log4net.Layout.PatternLayout">
				<conversionPattern value="%m%newline" />
			</layout>
			<appendToFile value="true" />
			<maximumFileSize value="100KB" />
			<maxSizeRollBackups value="2" />
		</appender>
etc...

My C# application does this:

        private static readonly ILog bllDebugLog =
LogManager.GetLogger("Matrix.Trace"); //for debugging

and

            log4net.Config.XmlConfigurator.ConfigureAndWatch(new
System.IO.FileInfo("log4net.config"));

If I use the default locking method, logging does work (but I have file-lock
problems with multiple processes, which is what I am trying to resolve).

I cannot see from the log4net documentation why this should fail. What am I
doing wrong?

TIA

--
View this message in context: http://apache-logging.6191.n7.nabble.com/Multiple-processes-logging-to-single-file-unexplained-error-message-tp42667.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

George Mauer | 4 Dec 21:16 2013
Picon

Re: How to dynamically query and set logger levels?


I would like to create an area in my application that will let sysadmins modify logger levels directly.

This stackoverflow answer from 2009 implies that I can do it with

foreach (ILog logger in log4net.LogManager.GetCurrentLoggers()) { ((log4net.Repository.Hierarchy.Logger)logger).Level = log4net.Core.Level.Error; }

My application uses log4net 2.0.3 (1.2.13) and this seems to not be available as no implementation of ILog inherits that class. 

Instead I can grab each ILog's instances of ILogger to give me the name but will not let me query or set the Level. There is nothing I can cast this to in the meantime as it seems to be implemented by an internal class.

PS. How exactly does the email confirmation protect me from someone subscribing falsely? I subscribed by emailing from this address!
Stefan Bodewig | 21 Nov 15:05 2013
Picon

[ANN] Apache log4net 1.2.13 Released


The Apache log4net team is pleased to announce the release of Apache
log4net 1.2.13.  The release is available for download at

        http://logging.apache.org/log4net/download.html

The Apache log4net library is a tool to help the programmer output log
statements to a variety of output targets.  log4net is a port of the
excellent Apache log4j framework to the Microsoft(R) .NET runtime.

The log4net 1.2.13 release fixes a problem with stack frames of dynamic
methods in .NET 4.0 as well as a few regressions introduced with 1.2.12.
The assemblies built for .NET 3.5 (CP) now also contain the ILog
extensions methods.

See the release-notes at

    http://logging.apache.org/log4net/release/release-notes.html

for a full list of changes.

Please verify signatures using the KEYS file available at the above
location when downloading the release.

For complete information on log4net, including instructions on how to
submit bug reports, patches, or suggestions for improvement, see the
Apache log4net website:

http://logging.apache.org/log4net/

Stefan Bodewig on behalf of the log4net community

Gmane