Re: aspnetrequest server variables' values
It's not possible using any of the built-in patterns although it should be simple enough to write your own: // untestedpublic class AspNetRequestServerPatternConverter : PatternLayoutConverter{ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent) { if (HttpContext.Current != null && HttpContext.Current.Request != null) { writer.Write(HttpContext.Current.Request.ServerVariables[Option]); } else { writer.Write(SystemInfo.NotAvailableText); } }} I'll look into adding something similar to /trunk From: Shivinder SinghTo: "log4net-user@logging.apache.org" Sent: Monday, March 7, 2016 10:30 AM Subject: aspnetrequest server variables' values How/where can I get the values of server variables logged by the aspnet-request conversion pattern? This is what I'm getting currently for my ASP.NET MVC application. {ASP.NET_SessionId, ALL_HTTP, ALL_RAW, APPL_MD_PATH, APPL_PHYSICAL_PATH, AUTH_TYPE, AUTH_USER, AUTH_PASSWORD, LOGON_USER, REMOTE_USER, CERT_COOKIE, CERT_FLAGS, CERT_ISSUER, CERT_KEYSIZE, CERT_SECRETKEYSIZE, CERT_SERIALNUMBER, CERT_SERVER_ISSUER, CERT_SERVER_SUBJECT, CERT_SUBJECT, CONTENT_LENGTH, CONTENT_TYPE, GATEWAY_INTERFACE, HTTPS, HTTPS_KEYSIZE, HTTPS_SECRETKEYSIZE, HTTPS_SERVER_ISSUER, HTTPS_SERVER_SUBJECT, INSTANCE_ID, INSTANCE_META_PATH, LOCAL_ADDR, PATH_INFO, PATH_TRANSLATED, QUERY_STRING, REMOTE_ADDR, REMOTE_HOST, REMOTE_PORT, REQUEST_METHOD, SCRIPT_NAME, SERVER_NAME, SERVER_PORT, SERVER_PORT_SECURE, SERVER_PROTOCOL, SERVER_SOFTWARE, URL, HTTP_CONNECTION, HTTP_ACCEPT, HTTP_ACCEPT_ENCODING, HTTP_ACCEPT_LANGUAGE, HTTP_COOKIE, HTTP_HOST, HTTP_USER_AGENT}
Re: Log file availability issue
You can use a minimal lock on your FileAppender: lockingModel type=log4net.Appender.FileAppender+MinimalLock / but it'll slow things down because it will open and close the file with each write. I've used code like this before to open a locked file: // from http://www.ericbt.com/Blog/48 using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { using (StreamReader streamReader = new StreamReader(fileStream)) { logFileText = streamReader.ReadToEnd(); } } From: Chu, Greg greg@wendys.com To: log4net-user@logging.apache.org log4net-user@logging.apache.org Sent: Wednesday, June 12, 2013 9:44 AM Subject: Log file availability issue During the application running the log file is locked. I am trying to email the log file inside the application while the application is running. Do I have any way to close the log file so it is unlocked, so that I can get the log file and email it? Thanks Greg Notice: This e-mail message and its attachments are the property of The Wendy's Company or one of its subsidiaries and may contain confidential or legally privileged information intended solely for the use of the addressee(s). If you are not an intended recipient, then any use, copying or distribution of this message or its attachments is strictly prohibited. If you received this message in error, please notify the sender and delete this message entirely from your system.
Re: ThreadID not changing
What happens when you retrieve the current thread id on your own and include it in the log message? Does it match %t? I believe LoggingEvent by default captures the current thread id at the time the log is being generated then makes that available as %t. FixFlags is the property name. I think FixFlags.Partial is the default: http://logging.apache.org/log4net/release/sdk/log4net.Core.FixFlags.html From: Randar101 randar.pu...@blueprintsys.com To: log4net-user@logging.apache.org Sent: Friday, May 3, 2013 10:53 AM Subject: ThreadID not changing We have an application that has the following architecture: -IIS -WCF RIA Services. -Silverlight client -We log on both the client and the server and use Clog to send the logs from the client My issue is with our server logs. Whenever log4net logs the threadId, it seems to be the same until something big happens (i.e. IIS Reset). So the log file looks like this even though these are two users hitting it at the same time. Server: 02/05/2013 18:16:16, GMT-05:00, ThreadId:179, , TestUser3, Debug,Currently logged in as TestUser3 Server: 02/05/2013 18:16:16, GMT-05:00, ThreadId:179, uo2sexbeikaej0hpwoiylxxz, TestUser3, Debug,Initializing UserManagementDomainService Server: 02/05/2013 18:16:16, GMT-05:00, ThreadId:179, uo2sexbeikaej0hpwoiylxxz, TestUser3, Debug,[UserManagementDomainService] running query [GetUserManagementCacheData] Thread[146] Instance[New] Server: 02/05/2013 18:16:16, GMT-05:00, ThreadId:179, , , Debug,Begin [/Services/TheApplicationSys-RC-Client-RIA-Models-Services-SettingsDomainService.svc/Soap] Type=Service,IP=::1 Server: 02/05/2013 18:16:16, GMT-05:00, ThreadId:179, , TestUser6, Debug,Currently logged in as TestUser6 Server: 02/05/2013 18:16:16, GMT-05:00, ThreadId:179, u5avnhurwzctmzrep1sxafw1, TestUser6, Debug,Initializing SettingsDomainService Server: 02/05/2013 18:16:16, GMT-05:00, 149, u5avnhurwzctmzrep1sxafw1, TestUser6, GetUserDictionary, [PROFILING], 11, 5001fe21-7d56-4719-89af-510674543765, Server: 02/05/2013 18:16:16, GMT-05:00, ThreadId:179, , TestUser6, Debug,End [/Services/TheApplicationSys-RC-Client-RIA-Models-Services-SettingsDomainService.svc/Soap] Type=Service,IP=::1,Page=TheApplicationSys-RC-Client-RIA-Models-Services-SettingsDomainService.svc;Duration=11.670ms,User=TestUser6 Server: 02/05/2013 18:16:16, GMT-05:00, ThreadId:179, , , Debug,Begin [/Services/TheApplicationSys-RC-Client-RIA-Models-Services-FeatureLicenseDomainService.svc/Soap] Type=Service,IP=::1 Server: 02/05/2013 18:16:16, GMT-05:00, ThreadId:179, , TestUser6, Debug,Currently logged in as TestUser6 Server: 02/05/2013 18:16:16, GMT-05:00, ThreadId:179, u5avnhurwzctmzrep1sxafw1, TestUser6, Debug,Initializing FeatureLicenseDomainService Once something happens, the thread ID changes and is then consistently that number. Looking through our code, we don't explicitly set the threadID, so it has to coming form Log4net. There is nothing that would lead us to believe that our application is actually single threaded. We are setup for “Single” ConcurrencyMode and “PerSession”, which means that every unique client may get a new thread. We run some fairly heavy load tests and can see what looks very much like parallel activity. I've looked at our log files for very busy environments (production, QA, etc.) and they all seem to behave the same. So at this point, it feels like a logging issue and not a threading issue. Has anybody seen this or have a solution? The appender is as follows: appender name=ServerFileAppender type=log4net.Appender.RollingFileAppender file value=Log\TheApplication.log / appendToFile value=true / lockingModel type=log4net.Appender.FileAppender+MinimalLock / maxSizeRollBackups value=2 / rollingStyle value=Size / maximumFileSize value=10MB / countDirection value=1/ layout type=log4net.Layout.PatternLayout conversionPattern value=%property{logId}: %date{dd/MM/ HH:mm:ss}, %property{timeZoneOffset}, ThreadId:%t, %property{sessionId}, %property{userName}, %property{level},%message%newline / /layout /appender -- View this message in context: http://apache-logging.6191.n7.nabble.com/ThreadID-not-changing-tp37154.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Log4Net logs incorrect data
Add a custom converter to your PatternLayout: layout type=log4net.Layout.PatternLayout converter name value=operationContext / type value=MyCompany.Logging.Layout.Pattern.OperationContextPatternConverter / /converter conversionPattern value=%5level %date - %operationContext{Status} - %message%newline / /layout Or extend PatternLayout if you're going to re-use the converter across multiple appenders: layout type=MyCompany.Logging.Layout.PatternLayout conversionPattern value=%5level %date - %operationContext{Status} - %message%newline / /layout From: Joseph.r rajesh.jos...@gmail.com To: log4net-user@logging.apache.org Sent: Saturday, June 2, 2012 9:20 PM Subject: Re: Log4Net logs incorrect data Thank you. Will try this. However, if I go with this, how would I set the pattern converter in the Web.config file to use the operationcontext{Status}. Anyways, appreciate it. Ron Grabowski wrote: GlobalContext doesn't seem like the right place if you want to keep instance level values. If you've designed a WCF app why not just store things in OperationContext then make a PatternConverter to pull from there? %d %level %oc{Status} %m%n From: Joseph.r rajesh.jos...@gmail.com To: log4net-user@logging.apache.org Sent: Friday, June 1, 2012 2:24 PM Subject: Log4Net logs incorrect data I have a WCF service where in I use Log4Net for logging information to Sql Server database. I use Log4Net's GlobalContext to log some extra information, like Transaction Name, Status, Message, and few other stuff. Some of the important transactions within this system are Read, Write and Login. The log should look like: Read Success Read xxx customer data Write Success Written xxx customer's data Login Failure User session already exists. Everything works fine when I run my normal tests - the logs are written to the database perfectly. However, recently I did a load test by using JMeter. The above mentioned three transactions were tested in 100 concurrent threads for 3 minutes. When I checked the DB logs, I found that some of the information were logged incorrectly. Ex: Read Success User session already exists. Write Success Read xxx customer data Is this an issue with Log4Net GlobalContext not being thread safe? I tried using ThreadContext instead of GlobalContext, but looks like lots of information were not logged. -- View this message in context: http://old.nabble.com/Log4Net-logs-incorrect-data-tp33946524p33946524.html Sent from the Log4net - Users mailing list archive at Nabble.com. -- View this message in context: http://old.nabble.com/Log4Net-logs-incorrect-data-tp33946524p33951719.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: ILog Wrapping
The original poster specifically mentioned he did not want to have to walk to the call stack. Log4net internally walks the call stack so there's no need to walk it twice. The Stack Overflow article is correct. Here's another example: http://svn.apache.org/viewvc/ibatis/cs/ibatisnet-1/trunk/src/IBatisNet.Common.Logging.Log4Net/ The key concept is needing to pass in the Type of your wrapper to the actually log method so log4net knows to skip over that stack frame when its processing call information. From: Martin Milan martin.mi...@enservegroup.com To: Log4NET User log4net-user@logging.apache.org Sent: Friday, June 1, 2012 4:13 AM Subject: RE: ILog Wrapping Can you not walk the call stack until you come across a method that is not from the same namespace as your wrapper? Just an idea… From:Andreas HOELZLWIMMER [mailto:andreas.hoelzlwim...@racon.at] Sent: 01 June 2012 08:36 To: log4net-user@logging.apache.org Subject: ILog Wrapping Hi, I need to switch our logger to Log4Net in our application. I need to implement our personal logging interface, which means I need to wrap the Logger. The logger requires to display method name and namespace. With the usual way it always shows the method and namespace of the wrapper, not the method called. The option found on stackoverflow (http://stackoverflow.com/questions/157232/how-to-log-methodname-when-wrapping-log4net) does not help and I wanted to know if there is a way to log the correct method/namespace without having to go back in the call stack. Is there a best practise for wrapping ILog? best regards, Andreas Der Austausch von Nachrichten mit o.a. Absender via e-mail dient ausschließlich Informationszwecken. Rechtsgeschäftliche Erklärungen dürfen über dieses Medium nicht ausgetauscht werden. Correspondence with a.m. sender via e-mail is only for information purposes. This medium is not to be used for the exchange of legally-binding communications.Enserve Group Legal Disclaimer EnServe Group Limited (EnServe), registered in England and Wales with registration number 3250709.EnServe's registered office is at Hertsmere House, Shenley Road, Borehamwood, Herts, WD6 1TE, United Kingdom and a list of EnServe's subsidiaries and their registered particulars is available for inspection at this location. This email and any attachments to it are confidential and are intended solely for the use of the individual to whom it is addressed. Any views or opinions expressed are solely those of the author and do not necessarily represent those of EnServe or its subsidiaries. If you are not the intended recipient of this email, you must neither take any action based upon its contents, nor copy or show it to anyone. Please contact the sender if you believe you have received this email in error. This message has been scanned by Symantec Mail Security
Re: Log4Net logs incorrect data
GlobalContext doesn't seem like the right place if you want to keep instance level values. If you've designed a WCF app why not just store things in OperationContext then make a PatternConverter to pull from there? %d %level %oc{Status} %m%n From: Joseph.r rajesh.jos...@gmail.com To: log4net-user@logging.apache.org Sent: Friday, June 1, 2012 2:24 PM Subject: Log4Net logs incorrect data I have a WCF service where in I use Log4Net for logging information to Sql Server database. I use Log4Net's GlobalContext to log some extra information, like Transaction Name, Status, Message, and few other stuff. Some of the important transactions within this system are Read, Write and Login. The log should look like: Read Success Read xxx customer data Write Success Written xxx customer's data Login Failure User session already exists. Everything works fine when I run my normal tests - the logs are written to the database perfectly. However, recently I did a load test by using JMeter. The above mentioned three transactions were tested in 100 concurrent threads for 3 minutes. When I checked the DB logs, I found that some of the information were logged incorrectly. Ex: Read Success User session already exists. Write Success Read xxx customer data Is this an issue with Log4Net GlobalContext not being thread safe? I tried using ThreadContext instead of GlobalContext, but looks like lots of information were not logged. -- View this message in context: http://old.nabble.com/Log4Net-logs-incorrect-data-tp33946524p33946524.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Inconsistency of internal logging and behavior in log4net in ASP.NET MVC (multi-assembly)
Is Common.Logging your wrapper around log4net or another library? From: Todd Webb webbjt...@gmail.com To: log4net-user@logging.apache.org Sent: Thursday, May 24, 2012 9:42 AM Subject: Inconsistency of internal logging and behavior in log4net in ASP.NET MVC (multi-assembly) I have a multi-assembly ASP.NET MVC application. I reviewed the recent posts on a similar topic, but decided that my problem merited a new thread. I am configuring log4net is a separate configuration file and initialize log4net with this statement: [assembly: log4net.Config.XmlConfigurator(ConfigFile = WebApplication.log4net, Watch=true)] I am attempting to log from the web application assembly and from another assembly in the solution. I enabled log4net internal logging and received the following: log4net: XmlConfigurator: loading XML configuration log4net: XmlConfigurator: Configuring Repository [log4net-default-repository] log4net: XmlHierarchyConfigurator: Configuration update mode [Merge]. log4net: XmlHierarchyConfigurator: Logger [root] Level string is [ERROR]. log4net: XmlHierarchyConfigurator: Logger [root] level set to [name=ERROR,value=7]. log4net: XmlHierarchyConfigurator: Loading Appender [DebugAppender] type: [log4net.Appender.DebugAppender] log4net: XmlHierarchyConfigurator: Setting Property [ImmediateFlush] to Boolean value [True] log4net: XmlHierarchyConfigurator: Setting Property [Layout] to object [log4net.Layout.SimpleLayout] log4net: XmlHierarchyConfigurator: Created Appender [DebugAppender] log4net: XmlHierarchyConfigurator: Adding appender named [DebugAppender] to logger [root]. log4net: XmlHierarchyConfigurator: Retrieving an instance of log4net.Repository.Logger for logger [WebApplication.Controllers.AppController]. log4net: XmlHierarchyConfigurator: Setting [WebApplication.Controllers.AppController] additivity to [True]. log4net: XmlHierarchyConfigurator: Logger [WebApplication.Controllers.AppController] Level string is [DEBUG]. log4net: XmlHierarchyConfigurator: Logger [WebApplication.Controllers.AppController] level set to [name=DEBUG,value=3]. log4net: XmlHierarchyConfigurator: Adding appender named [DebugAppender] to logger [WebApplication.Controllers.AppController]. log4net: XmlHierarchyConfigurator: Retrieving an instance of log4net.Repository.Logger for logger [WebApplication.Domain.Implementation.DomainImpl]. log4net: XmlHierarchyConfigurator: Setting [WebApplication.Domain.Implementation.DomainImpl] additivity to [True]. log4net: XmlHierarchyConfigurator: Logger [WebApplication.Domain.Implementation.DomainImpl] Level string is [DEBUG]. log4net: XmlHierarchyConfigurator: Logger [WebApplication.Domain.Implementation.DomainImpl] level set to [name=DEBUG,value=3]. log4net: XmlHierarchyConfigurator: Adding appender named [DebugAppender] to logger [WebApplication.Domain.Implementation.DomainImpl]. log4net: XmlHierarchyConfigurator: Hierarchy Threshold [] I am interested in the logger at WebApplication.Domain.Implementation.DomainImpl and see that it is set to debug. However, when I access the logger in the debugger and print its state I get this: DomainImpl.log {Common.Logging.Simple.NoOpLogger} Common.Logging.ILog {Common.Logging.Simple.NoOpLogger} [Common.Logging.Simple.NoOpLogger] {Common.Logging.Simple.NoOpLogger} Common.Logging.Simple.NoOpLogger IsDebugEnabled false bool IsErrorEnabled false bool IsFatalEnabled false bool IsInfoEnabled false bool IsTraceEnabled false bool IsWarnEnabled false bool The only thing that made sense to me was that I was accessing a different logger in my code than the one that was referenced in the log4net log. However, I only see two loggers created, one each for my web application and domain assemblies. I don’t see any logger created that has no logging levels enabled. I am stumped and welcome any guidance. For example, when should I get a NoOpLogger?
Re: Logger in ASP.NET stops after a few hours, won't restart until app is cycled
Have you tried setting the Evaluator property: http://logging.apache.org/log4net/release/sdk/log4net.Appender.BufferingAppenderSkeleton.Evaluator.html to flush buffered messages when a WARN or greater message is received? Sounds like you have a good plan for extending the built-in appender for your project. Shouldn't be too difficult to add a timer that triggers a flush every X seconds. Be careful that your buffer doesn't grow too large if the database is down for an extended period of time. What you might want to do is extend BufferingForwardingAppender in such a way that it supports the concept of a fail-over appenders. I think nlog ships with a target that is able to switch destinations if the first one goes offline. I believe it tries to log to the original appender on each write to the fail-over appender because it wants to get back to the primary destination as soon as possible. I'm not certain about the implementation. From: Jim Scott jsc...@infoconex.com To: log4net-user@logging.apache.org Sent: Wednesday, January 11, 2012 7:58 PM Subject: Re: Logger in ASP.NET stops after a few hours, won't restart until app is cycled FYI, here is the enhancements that I suggested back in Jan, 2011 that I was referring to in my last email. I have been using the AdoNetAppender for a while now and have a few issues with it. 1)If the database that it logs to goes offline it will stop logging messages until the application is restarted ·You can overcome that issue by setting ReconnectOnError but the problem with that is that if the database is still offline it will block your program thread until it times out every time it tries to flush the events. 2)Since the AdoNetAppender derives from BufferAppenderSkeleton it buffers events before writing to the DB. Not a bad idea unless you want to monitor the DB for exceptions in real-time. So let’s say I set the default buffer size to 20 events. If I am monitoring the DB I won’t see any of the exceptions till it hits the buffer size of 20 events. ·The fix for me is to set the buffer to 1 event so that I get real-time results when an exception happens. However I am not taking advantage of buffering the events so that the application thread returns quicker and writes to the DB less frequent. Here is the behavior I want. 1)Set by default buffer size to 100 2)Set a buffer flush interval to 60 seconds 3)Set retry logic for DB connection in the event that the DB is unavailable and cache the log events being written So here is an example of how it would work. Write an exception to AdoNetAppender Event is buffered If buffer exceeds 100 events or 60 seconds has elapsed the buffer will be flushed If the appender is unable to talk to the DB it marks the connection as failed and caches the events locally Next write attempts looks to see if the retry time has been exceeded and if so attempts to write buffer to DB Also any local events previously cached from a failure will be written as well. So now I am back to using a buffer I now see any exceptions at most 60 seconds after they happen If the DB goes down I now have retry logic for attempting to write the events (key is not every attempt so the application is not being blocked on every write) Now not being entirely familiar with the source for Log4Net I attempted to add these features and have it working. However not sure if my approach is the approach you would take for including in your source. If anyone likes the features listed above I would be happy to provide the source changes. I did this by creating a AdoNetAppenderEx class that looks just like the AdoNetAppender but with my additions. However I personally think the concept of flushing events on an interval should be coded up higher in the BufferAppenderSkeleton as the issue I don’t like is having to wait till the number of buffered events is exceeded. Would be nice to specify another threshold for buffered events to be time based. The retry logic however for the DB is essential but don’t want it happening on every write but rather a retry after X seconds has elapsed since the last failed connection.
Re: Email alert from log4net
You could extend BufferingForwardingAppender to wrap your original appender and add logic for sending mail when there's too much traffic after inspecting the buffer and to stop messages from forwarding until a certain timeout period has passed.From: "Venkatasamy, Vanitha" vanitha.venkatas...@xpandcorp.comTo: Log4NET User log4net-user@logging.apache.orgSent: Thursday, October 27, 2011 11:37 AMSubject: Email alert from log4net Hi , I need some idea to implement the following requirement in the web application . I am using log4net in a custom dll to log the errors. I completed the log4net implementation and its working fine.[aspx errors are logged in Event Log and the asp errors are logged in FileAppender] .All the .loggerError() methods are in the custom dll. Now I want to monitor the logging, suppose if there is a situation like the .loggerError() method is called more than 10 times in just 15 mins because of Fatal error or if database is down, then I want to track that and send email to admin. Is anybody implemented similar requirement or is there any solution in Log4net. 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.
Re: Log4Net Error on DB Connect AdoNetAppender
Try adding an ErrorHandler on the appender: http://logging.apache.org/log4net/release/sdk/log4net.Core.IErrorHandler.html AdoNetAppender adoAppender = newAdoNetAppender(); adoAppender.ErrorHandler = new FileAppenderErrorHandler(); From: meisenstein meisenst...@connectivityreport.com To: log4net-user@logging.apache.org Sent: Monday, July 11, 2011 9:42 AM Subject: Log4Net Error on DB Connect AdoNetAppender I have my AdoNetAppender as code instead of as a XML config file, log4net.Appender.AdoNetAppender adoAppender = new log4net.Appender.AdoNetAppender(); I would like to catch an error if the database it's trying to connect to is down, so that I can switch over to the file appender. This is where my problem arises, Log4Net seems to consume the errors and echo the error to the console instead of throwing it back again. I've wrapped my AdoNetAppender in a try catch: catch (Exception ex) { LoadFileAppender(level); Log log = new Log(AdoAdaptorFail); log.Error(AdoAdaptor Failed, System, ex); } to load the file appender and log the error, however ..it never comes here because Log4Net consumes the error and writes it to the console... Is there ANY WAY i can catch this configuration error to load the file appender? Thanks -- View this message in context: http://old.nabble.com/Log4Net-Error-on-DB-Connect-AdoNetAppender-tp32037558p32037558.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: RollingFileAppender does not seem to preserve old log messages
When I change your code to: for (int i1 = 0; i1 = 20; i1++) { for (int i2 = 0; i2 1000; i2++) { log.Debug( + i2 + + superLongText); } } the 3 files are created. The small file size after 20 runs is probably caused because one of the files is 10mb and the other file has been reset. I'm not sure why that occurs but it seems like the RFA maintains some sort of internal roll over state that isn't preserved when the program starts up again. From: Lee Chun Kit chunki...@gmail.com To: log4net-user@logging.apache.org Sent: Monday, April 4, 2011 5:54 AM Subject: RollingFileAppender does not seem to preserve old log messages Here is the configuration xml I am using: log4net debug=true appender name=RollingLogFileAppender type=log4net.Appender.RollingFileAppender lockingModel type=log4net.Appender.FileAppender+ExclusiveLock / file value=./output/ / appendToFile value=true / rollingStyle value=Composite / datePattern value='LoggerTest'MMdd'.log' / maxSizeRollBackups value=-1 / maximumFileSize value=10MB / staticLogFileName value=false / layout type=log4net.Layout.PatternLayout conversionPattern value=%date [%level] %message%newline / /layout /appender logger name=Logger additivity=false level value=DEBUG / appender-ref ref=RollingLogFileAppender / /logger /log4net --- Here are the significant portions of my code: static readonly string superLongText = new string('a', 1024); static readonly log4net.ILog log = log4net.LogManager.GetLogger(Logger); static void Main(string[] args) { log4net.Config.XmlConfigurator.Configure(./TestConfig.xml))); for (int i = 0; i 1000; i++) { log.Debug( + i + + superLongText); } } --- Total size (in bytes) of the generated logs after each execution of my program: 01: 1061890 02: 2123780 03: 3185670 04: 4247560 05: 5309450 06: 6371340 07: 7433230 08: 8495120 09: 9557010 10: 10618900 11: 11680790 12: 12742680 13: 13804570 14: 14866460 15: 15928350 16: 16990240 17: 18052130 18: 19114020 19: 20175910 20: 10751650 --- log files: LoggerTest20110404.log LoggerTest20110404.log.1 --- After run 19, LoggerTest20110404.log is 9463KB (almost 10MB), and LoggerTest20110404.log.1 is 10241KB. After run 20, LoggerTest20110404.log is 260KB, and LoggerTest20110404.log.1 is 10241KB. However, file LoggerTest20110404.log.2 is not created (I expect the logger to do so). Does anyone know why is it the case that the log information is not preserved between run 19 and run 20? May I know if it is an error in my xml configuration or a limitation of the RollingFileAppender and the combination of settings I used? Thanks. Regards, Chun Kit
Re: How To Ignore Unregistered AppDomain Messages
Are you sure that's a log4net generated message? - Original Message From: keyoh bobga...@gmail.com To: log4net-user@logging.apache.org Sent: Tue, August 10, 2010 1:58:49 PM Subject: How To Ignore Unregistered AppDomain Messages When my classes are created I get these messages: Unregistered AppDomain unhandled exception handler. Registered AppDomain unhandled exception handler. How can I set the text logger to ignore these? -- View this message in context: http://old.nabble.com/How-To-Ignore-Unregistered-AppDomain-Messages-tp29400550p29400550.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Problem regarding LoggerManager
Your wrapper needs to pass its Type into log4net's Log method so the code that processes StackTrace information knows to skip over certain frames: http://code.google.com/p/mybatisnet/source/browse/tags/cs%20release%201.3/IBatisNet.Common.Logging.Log4Net/Log4NetLogger.cs public class MyCompanysWrapperLogger : ILog { private readonly static Type _declaringType = typeof(MyCompanysWrapperLogger); private ILogger _log4netLogger; internal MyCompanysWrapperLogger(ILog log) { _log4netLogger = log.Logger; } public void Info(object message, Exception e) { _logger.Log(declaringType, log4net.Core.Level.Info, message, e); } } - Original Message From: oritne ori...@gmail.com To: log4net-user@logging.apache.org Sent: Mon, June 7, 2010 10:10:12 AM Subject: Problem regarding LoggerManager Hi, I really need help on this issue. I've looked for a solution everywhere but haven't found one. Here is my problem: In the company I work for, A log4net wrapper is being used in order to write logs into files (and database). The problem is, that when I try to write details as line number and file name into the log file, I get question marks, and it happens IN DEBUG MODE, where I have a pdb file. I've done some testing and found out that it happens only when I use LoggerManager object. If I use LogManager object it works just fine. Here is how I use it: The Log.config: logger name=CodeExamples.Program level value=DEBUG/ appender-ref ref=Global / /logger appender name=Global type=log4net.Appender.RollingFileAppender layout type=log4net.Layout.PatternLayout /layout /appender This piece of code prints out the question marks: private ILogger logger; log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(D:\\Projects\\CodeExamples\\bin\\Debug\\Log.config)); logger = LoggerManager.GetLogger(Assembly.GetCallingAssembly(), MethodBaseType.FullName); logger.Log(MethodBaseType, Level.Error, Message, null); Here is its output: [07 06 2010 16:11:09,343] ERROR: Attempted to divide by zero.; Logger: CodeExamples.Program; File: ?; Line: ?; Type: ?; This one works just fine: private ILog log; log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(D:\\Projects\\CodeExamples\\bin\\Debug\\Log.config)); log = LogManager.GetLogger(Assembly.GetCallingAssembly(), MethodBaseType.FullName); log.Error(Message, null); and the output: [07 06 2010 16:11:09,365] ERROR: Attempted to divide by zero.; Logger: CodeExamples.Program; File: D:\Projects\MyLogger\MyLog.cs; Line: 41; Type: MyLogger.MyLog; If I could, I would use only LogManager, but the wrapper I work with uses the LoggerManager, and touching it is the last thing I want to do... Any help will be appreciated! Thanks. -- View this message in context: http://old.nabble.com/Problem-regarding-LoggerManager-tp28805753p28805753.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Unable to log to database
Do you get the same errors if you use the shorter syntax from the log4net website: layout type=log4net.Layout.PatternLayout value=%level / From: Sachin Nair sachin.r.n...@gmail.com To: log4net-user@logging.apache.org Sent: Tue, May 25, 2010 7:27:28 AM Subject: Unable to log to database Hi, I am using powershell to log some information to database. Here are the details. 1. Code: Log4NetTest.ps1 $ErrorActionPreference=Stop # load the log4net library [void][Reflection.Assembly]::LoadFile(C:\Log4netTest\log4net.dll) # Reset any log4net configuration to defaults. [log4net.LogManager]::ResetConfiguration() # configure logging $configFileInfo = gi C:\Log4netTest\log4net.xml [log4net.Config.XmlConfigurator]::ConfigureAndWatch($configFileInfo) $logger = [log4net.LogManager]::GetLogger(MyLogs) $logger.info(Started) try { $logger.info(Trying to create a file in the current directory ...) New-Item -ItemType file test.txt $logger.info(Trying to create the same file again in the current directory ...) New-Item -ItemType file test.txt } catch { $logger.Error(You have an error) $logger.Fatal($_.Exception.message) $logger.Fatal($_.Exception.Message,$_.Exception) } finally { $logger.Info(Ended) } 2. Configuration file : log4net.xml !-- This section contains the log4net configuration settings -- log4net !-- Example of how to configure the AdoNetAppender to connect to MS SQL Server -- appender name=ADONetAppender_SqlServer type=log4net.Appender.AdoNetAppender bufferSize value=1 / connectionType value=System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 / connectionString value=data source=[Sqlserver];initial catalog=[Database];integrated security=false;persist security info=True;User ID=sa;Password=[password] / commandText value=INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message]) VALUES (@log_date, @thread, @log_level, @logger, @message) / parameter parameterName value=@log_date / dbType value=DateTime / layout type=log4net.Layout.RawTimeStampLayout / /parameter parameter parameterName value=@log_level / dbType value=String / size value=50 / layout type=log4net.Layout.PatternLayout conversionPattern value=%level / /layout /parameter parameter parameterName value=@thread / dbType value=String / size value=255 / layout type=log4net.Layout.PatternLayout conversionPattern value=%thread / /layout /parameter parameter parameterName value=@log_level / dbType value=String / size value=50 / layout type=log4net.Layout.PatternLayout conversionPattern value=%level / /layout /parameter parameter parameterName value=@logger / dbType value=String / size value=255 / layout type=log4net.Layout.PatternLayout conversionPattern value=%logger / /layout /parameter parameter parameterName value=@message / dbType value=String / size value=4000 / layout type=log4net.Layout.PatternLayout conversionPattern value=%message / /layout /parameter /appender !-- Setup the root category, add the appenders and set the default level -- root level value=ALL / appender-ref ref=ADONetAppender_SqlServer / /root !-- Specify the level for some specific categories -- logger name=MyLogs level value=ALL / appender-ref ref=ADONetAppender_SqlServer / /logger /log4net 3. Table : CREATE TABLE [dbo].[Log] ( [Id] [int] IDENTITY (1, 1) NOT NULL, [Date] [datetime] NOT NULL, [Thread] [varchar] (255) NOT NULL, [Level] [varchar] (50) NOT NULL, [Logger] [varchar] (255) NOT NULL, [Message] [varchar] (4000) NOT NULL, [Exception] [varchar] (2000) NULL ) Output : output.txt PS C:\Log4netTest .\Log4NetTest.ps1 log4net:ERROR XmlHierarchyConfigurator: Could not create Appender [ADONetAppender_SqlServer] of type [log4net.Appender.A doNetAppender]. Reported error follows. System.ArgumentNullException: CreateConverterInstance cannot create instance, converterType is null Parameter name: converterType at log4net.Util.TypeConverters.ConverterRegistry.CreateConverterInstance(Type converterType) at log4net.Util.TypeConverters.ConverterRegistry.GetConverterFromAttribute(Type destinationType) at log4net.Util.TypeConverters.ConverterRegistry.GetConvertFrom(Type destinationType) at log4net.Util.OptionConverter.CanConvertTypeTo(Type sourceType, Type targetType) at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.CreateObjectFromXml(XmlElement element, Type defaultTargetTy pe, Type
Re: .NET 4?
.NET 4 runs 2.0 assemblies so you can use the .NET 2.0 assemblies for now. From: Chen Jin c...@helpathome.com To: Log4NET User log4net-user@logging.apache.org Sent: Tue, May 18, 2010 6:20:30 PM Subject: .NET 4? Hi All, I guess this is a simple question… Just want to make sure: If I use .NET4 VS2010, shall I recompile the log4net code or just use the current .NET 2 binary? Anyone has any experience? Thanks a lot! Chen
Re: Target of log
Ayende wrote a Sqlite appender: http://ayende.com/Blog/archive/2006/11/18/IntroducingRollingSqlAppender.aspx I think most people use the AdoNetAppender. I believe it also supports writing to SqlExpress. - Original Message From: Aleš Vojáček algid...@gmail.com To: Log4NET User log4net-user@logging.apache.org Sent: Mon, May 17, 2010 10:04:57 AM Subject: Target of log Hi all, looking for log storage, which will be fast enough for writes and fast enough for query. Nice one is MongoDB using http://github.com/jsk/log4net-MongoDB . But there is licencing problem, that we want to use log4net in commercial aplication but paying for logging store is hard to explain to our customer (and our Management). Have you some free alternative? Thank you A.
Re: AdoNetAppender field sizes
The config looks correct to me. Are you sure you want to use the .NET 1.0 version of System.Data? Does this make a difference? connectionTypevalue=System.Data.SqlClient.SqlConnection, System.Data / - Original Message From: Watson, Gary gary.wat...@nustarenergy.com To: log4net-user@logging.apache.org log4net-user@logging.apache.org Sent: Mon, May 10, 2010 8:19:48 AM Subject: AdoNetAppender field sizes Hello, I am using the AdoNetAppender in log4net to write error messages to a SQL Server 2000 database. Here is the configuration I am using, taken from my app.config file: configSections section name=log4net type=log4net.Config.Log4NetConfigurationSectionHandler, log4net / /configSections log4net appender name=ADONetAppender type=log4net.Appender.ADONetAppender bufferSize value=1 / connectionType value=System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 / connectionString value=Data Source=MHL1\SQL2000;Initial Catalog=Stocks;Integrated Security=true; / commandText value=INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception],[Context],[Username]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception, @context, @username) / parameter parameterName value=@log_date / dbType value=DateTime / layout type=log4net.Layout.RawTimeStampLayout / /parameter parameter parameterName value=@thread / dbType value=String / size value=32 / layout type=log4net.Layout.PatternLayout conversionPattern value=%t / /layout /parameter parameter parameterName value=@log_level / dbType value=String / size value=512 / layout type=log4net.Layout.PatternLayout conversionPattern value=%p / /layout /parameter parameter parameterName value=@context / dbType value=String / size value=512 / layout type=log4net.Layout.PatternLayout conversionPattern value=%x / /layout /parameter parameter parameterName value=@logger / dbType value=String / size value=512 / layout type=log4net.Layout.PatternLayout conversionPattern value=%c / /layout /parameter parameter parameterName value=@message / dbType value=String / size value=4000 / layout type=log4net.Layout.PatternLayout conversionPattern value=%m / /layout /parameter parameter parameterName value=@exception / dbType value=String / size value=2000 / layout type=log4net.Layout.ExceptionLayout / /parameter parameter parameterName value=@username / dbType value=String / size value=8 / layout type=log4net.Layout.PatternLayout conversionPattern value=%X{username} / /layout /parameter /appender root level value=ALL / appender-ref ref=ADONetAppender / /root /log4net I have created the Log table as referenced in the CommandText property with fields having the same names and sizes for each of the parameters. As you can see, the @exception parameter has a specified size of 2000 characters. However, the Exception values that are stored in the table after errors occur appear to be truncated at 256 characters. The code I am using to configure log4net is as follows: log4net.Config.XmlConfigurator.Configure() Dim h As log4net.Repository.Hierarchy.Hierarchy = CType(LogManager.GetRepository(), Repository.Hierarchy.Hierarchy) Dim ado As Appender.AdoNetAppender = CType(h.Root.GetAppender(ADONetAppender), Appender.AdoNetAppender) ado.ConnectionString = CGlobals.log4netConnectionString ado.ActivateOptions() log4net.GlobalContext.Properties(username) = Environment.UserName And when storing the error, here is the code that I use: Using log4net.NDC.Push(sContext) Dim l4nLog As ILog = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType) l4nLog.Error(sMessage) End Using Can anybody shed some light as to why this is happening? I am not truncating anything in code, and also cannot see anything in the log4net source to indicate that this would be happening there either. Thanks, Gary
Re: How to get line number and file name in custom Appender?
Some stacktrace information like line numbers are not available in release builds. - Original Message From: ITemplate itempl...@hotmail.com To: log4net-user@logging.apache.org Sent: Tue, May 4, 2010 4:24:49 PM Subject: Re: How to get line number and file name in custom Appender? Hi Yuriy, Thanks for your reply. I gotta say, I was a bit surprised to see that log4net per default could write out stack information - is the stacktrace collected at all times? It would seem so... -- Werner Yuriy Taraday wrote: http://logging.apache.org/log4net/release/sdk/log4net.Layout.PatternLayout.html Note about caller location information. The following patterns %type %file %line %method %location %class %C %F %L %l %M all generate caller location information. Location information uses the System.Diagnostics.StackTrace class to generate a call stack. The caller's information is then extracted from this stack. You should dig this way. But you better should not log this. Use Stacks/Properties instead to localize logging point in the source. It may not be as accurate as StackTrace but it is appropriate and reliable. On Tue, May 4, 2010 at 5:50 PM, ITemplate itempl...@hotmail.com wrote: Hi, Using a file appender, I can write the source code line number in my log file using %line. But if I have a custom Appender with the LoggingEvent - where is that information stored and retrievable? -- Werner -- View this message in context: http://old.nabble.com/How-to-get-line-number-and-file-name-in-custom-Appender--tp28447536p28447536.html Sent from the Log4net - Users mailing list archive at Nabble.com. -- View this message in context: http://old.nabble.com/How-to-get-line-number-and-file-name-in-custom-Appender--tp28447536p28452662.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Nested Config settings...
I'll commit this to svn too. #if NET_2_0 using System; using System.Collections.Generic; using System.Xml; using log4net.Appender; using log4net.Config; using log4net.Core; using log4net.Filter; using log4net.Repository; using NUnit.Framework; namespace log4net.Tests.Filter { [TestFixture] public class FilterTest { [Test] public void FilterConfigurationTest() { XmlDocument log4netConfig = new XmlDocument(); #region Load log4netConfig log4netConfig.LoadXml(@ log4net appender name=MemoryAppender type=log4net.Appender.MemoryAppender, log4net filter type=log4net.Tests.Filter.MultiplePropertyFilter, log4net.Tests condition key value=ABC / stringToMatch value=123 / /condition condition key value=DEF / stringToMatch value=456 / /condition /filter /appender root level value=ALL / appender-ref ref=MemoryAppender / /root /log4net); #endregion ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString()); XmlConfigurator.Configure(rep, log4netConfig[log4net]); IAppender[] appenders = LogManager.GetRepository(rep.Name).GetAppenders(); Assert.IsTrue(appenders.Length == 1); IAppender appender = Array.Find(appenders, a = a.Name == MemoryAppender); Assert.IsNotNull(appender); MultiplePropertyFilter multiplePropertyFilter = ((AppenderSkeleton)appender).FilterHead as MultiplePropertyFilter; var conditions = multiplePropertyFilter.GetConditions(); Assert.AreEqual(2, conditions.Length); Assert.AreEqual(ABC, conditions[0].Key); Assert.AreEqual(123, conditions[0].StringToMatch); Assert.AreEqual(DEF, conditions[1].Key); Assert.AreEqual(456, conditions[1].StringToMatch); } } public class MultiplePropertyFilter : FilterSkeleton { private readonly ListCondition _conditions = new ListCondition(); public override FilterDecision Decide(LoggingEvent loggingEvent) { return FilterDecision.Accept; } public Condition[] GetConditions() { return _conditions.ToArray(); } public void AddCondition(Condition condition) { _conditions.Add(condition); } public class Condition { public string Key { get; set; } public string StringToMatch { get; set; } } } } #endif From: Brian Carlson bcarl...@tier.com To: Log4NET User log4net-user@logging.apache.org Sent: Wed, April 21, 2010 2:03:55 PM Subject: Nested Config settings... I have a custom filter, doing an AND of multiple property checks. I need to be able to read in the following config… filter type=MyNameSpace.Logging.Appender.MultiplePropertyFilter,CommonUtilities Condition key value=”Property1” / stringToMatch value=”” / /Condition Condition key value=”Property2” / stringToMatch value=”bbb” / /Condition /filter Does anyone know how to implement this so my class has access to the nested nodes? Thanks, Brian
Re: Filters with AND/OR conditions.
If you can deploy your own assembly to the server that contains your custom filter that'll make your life a lot easier. I don't think what you want is possible using just the built-in filters. From: Brian Carlson bcarl...@tier.com To: Log4NET User log4net-user@logging.apache.org Sent: Tue, April 20, 2010 1:21:44 AM Subject: RE: Filters with AND/OR conditions. Ron, It’s likely going to need to be dynamic. Since once we turn on smtp notification, there might be other offenders that are identified and will need to be added. Brian From:Ron Grabowski [mailto:rongrabow...@yahoo.com] Sent: Monday, April 19, 2010 10:55 PM To: Log4NET User Subject: Re: Filters with AND/OR conditions. Can you deploy assemblies to the server and just hard-code your logic check using C#: public class MyFilter : FilterSkeleton { public override FilterDecision Decide(LoggingEvent loggingEvent) { /* If (Property1 = “111” Property2 = “abc” ) || (Property1 = ”111” Property2 = “bbb”) || (Property1 = ”222” Property2 = “def”) || (Property1 = ”333” Property2 = “xyz”)) Then Deny Else Accept */ } } or must it by dynamic? From:Brian Carlson bcarl...@tier.com To: log4net-user@logging.apache.org Sent: Mon, April 19, 2010 5:07:38 PM Subject: Filters with AND/OR conditions. I have 2 properties that I need to filter log messages based upon. I have setup an smtp appender for Error and Fatal log messages, but a couple components didn’t implement logging properly and are logging errors when they don’t exist. That problem is being dealt with. So I’m trying to take care of those messages with filters. What is the best way to setup something like this: If (Property1 = “111” Property2 = “abc” ) || (Property1 = ”111” Property2 = “bbb”) || (Property1 = ”222” Property2 = “def”) || (Property1 = ”333” Property2 = “xyz”)) Then Deny Else Accept Any help would be great. Thanks, Brian
Re: Possible to test log4net filters on certain logevent?
Have you looked into writing an log4net.ObjectRenderer.IObjectRenderer to render the message as text or is that not that possibility? Maybe this will work: // untested public class WouldLogAppender : ForwardingAppender { public bool WouldLog(LoggingEvent loggingEvent) { return FilterEvent(loggingEvent); } } You'd have to put your filters and thresholds on the WouldLogAppender instead of on the wrapped appender. - Original Message From: ITemplate itempl...@hotmail.com To: log4net-user@logging.apache.org Sent: Thu, April 15, 2010 3:36:20 AM Subject: Re: Possible to test log4net filters on certain logevent? Hi Loren, Thanks for your reply! Well there are a couple of reasons but as an example, we need to log special webservices where the request and responses are VERY large objects that log4net (or any other) can't serialize correct. We have our own serializer for that job. But at the same time, these web services must perform well and object serialization here is a rather expensive and time consuming task. So I would like the ability to test if the log system would actually log the data - and if not, I would not even begin to serialize the classes to text. But on the other hand I will not begin to dig too deep into log4net to accomplish this - it would only make sense if there were some easy way like: var mustSerialize = false foreach(var appender in log4net.Appenders) { mustSerialize = appender.WouldLog(logEvent); if (mustSerialize) break; } But digging deeper would drain the goal of saving the time to serialize I guess... -- Werner Loren Keagle wrote: I don't think that this is possible without some dangerous coding. Looking at the source code, there are no methods on any appenders to test the level/filter chain in advance. Given that your log4net config could contain dozens of appenders, each with their own set of filters, you could not make a single call to determine if an event would be filtered from all of them. Perhaps if you provided a little bit of context, someone here might be able to offer an alternative approach? If you really must have a programmatic way of doing this, you would have to gain access to all of your appenders, iterate through them, casting each to AppenderSkeleton (assuming the appender derives from this helper class!!!), test the log level of each, then iterate through all of the filters in the FilterHead linked list property. AppenderSkeleton has a protected method called FilterEvent that does all of this, but you cannot access it. It would probably have solved your problem if this method was part of the IAppender interface, but it's currently not accessible. So I suppose it is possible, but you're going to end up duplicating all of the logic that is already in AppenderSkeleton, which means you will be executing code twice. If you have multiple appenders, you will have to check each appender separately. ~Loren Keagle On 4/13/2010 6:18 AM, ITemplate wrote: Noone knows? Perhaps I could rephrase: I need a programmatic way to determine if a certain logentry would be filtered or not. Example: I have the following logentry: logger.Warn(This might be logged but I dont know. I want to test it in code.); Now I want to find out - at runtime - if that specific line in my code will produce a log. Some programmatic way to test one or all configured filters against the data in my log-line (Logger, Level, text etc). Hope my meaning here is more clearer? Thanks. ITemplate wrote: Hi, Is this old forum the only for log4net? Anyways - suppose I have a certain logevent, is it possible to investigate up front IF that particular logevent would pass all filters? I can't seem to find a Filters collection that I can use for this? -- Werner No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.801 / Virus Database: 271.1.1/2807 - Release Date: 04/12/10 11:32:00 -- View this message in context: http://old.nabble.com/Possible-to-test-log4net-filters-on-certain-logevent--tp28188373p28252058.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: file appender - file creation permissions
Can you do that with a FileStream? Aren't those types of permissions down another level beneath the Framework? - Original Message From: Igor Lautar igor.lau...@gmail.com To: log4net-user@logging.apache.org Sent: Mon, April 19, 2010 4:26:00 AM Subject: file appender - file creation permissions Hi All, I've search through documentation bug could not find answer to this question. We are using file appender to output logs to a file, minimal lock is used for locking model. We have encountered a problem where logs are not being written when output file already exists and is created by different user. The problem is in permissions. Is there a way to force created file permissions to be 'Everyone full control'? Thank you, Igor
Re: Request to Delete Content
Hrmm, never had a request to delete content. Even if it is deleted I would imagine it will live in some sort of cache on Google or the other engines for quite a while. I'm not a list admin. From: Rebecca bruchik...@gmail.com To: log4net-user@logging.apache.org Sent: Mon, January 25, 2010 2:13:31 PM Subject: Request to Delete Content Hi, Could you please do the necessary to delete the contents at following locations. See forwarded msg for details. http://www.mail-archive.com/log4net-user@logging.apache.org/msg03043.html http://www.mail-archive.com/log4net-user@logging.apache.org/msg03066.html http://mail-archives.apache.org/mod_mbox/logging-log4net-user/200604.mbox/date http://mail-archives.apache.org/mod_mbox/logging-log4net-user/200604.mbox/%3c015301c663d3$eaa18120$6500a...@daemon64%3e Thanks - Hide quoted text - -- Forwarded message -- From: Mail Archive Support themailarch...@gmail.com Date: Tue, Jan 19, 2010 at 7:26 PM Subject: Re: Request to delete a message To: Jenny G johng5...@gmail.com John, Thanks for writing. The Mail Archive's policy is to delete messages only with the approval of the list administrator. We are providing a free service for list administrators and the admin needs to be the final decision maker on archived list content. Please discuss your request with the list admin and have him contact us directly if he wishes to remove the post from the archive. Tom Support The Mail Archive
Re: log4net SVN seems inaccessible!?
https://svn.apache.org/repos/asf/logging/log4net/trunk - Original Message From: manfred.braun manfbr...@manfbraun.de To: log4net-user@logging.apache.org Sent: Wed, January 6, 2010 4:24:02 PM Subject: log4net SVN seems inaccessible!? Hi All ! I tried to checkout the lastest version of log4net from svn, but I receive only errors like this: RapidSVN error: Fehler beim Ausführen der Aktion: Repository moved temporarily to 'http://svn.apache.org/viewvc/logging/log4net/trunk'; please relocate TortoiseSVN: Checkout from http://svn.apache.org/viewvc/logging/log4net/trunk, revision HEAD, Fully recursive, Externals included Repository moved permanently to '/viewvc/logging/log4net/trunk/'; please relocate Are there any other addresses, wehere I can checkout a copy? Thanks a lot! br--mabra
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 lsmart...@gmail.com To: log4net-user@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
Re: precise time stamp
Do you want to control how the time is displayed in the log file or fundamentally alter how log4net tracks time? If you want to use a custom DateTime.Now to record when the event created you could start up by defining your own IDateTime: // untested public interface IDateTime { DateTime Now { get; } } then make it easy to get an instance of IDateTime: // untested public class DateTimeProvider : IDateTime { public static readonly DateTimeProvider DateTimeNow = new DateTimeProvider(() = DateTime.Now); public static readonly DateTimeProvider DateTimeUtcNow = new DateTimeProvider(() = DateTime.UtcNow); private FuncDateTime _dateTimeGetter; public DateTimeProvider(FuncDateTime dateTimeGetter) { _dateTimeGetter = dateTimeGetter; } public DateTime Now { get { return _dateTimeGetter(); } } public void SetDateTimeFunc(FuncDateTime dateTimeGetter) { _dateTimeGetter = dateTimeGetter; } } then you could tweak how the LoggingEventData object is created: // untested class DateTimeProviderLogger : LogImpl { private readonly static Type declaringType = typeof(DateTimeProviderLogger); private readonly IDateTime dateTimeProvider; public DateTimeProviderLogger(ILogger logger, IDateTime dateTimeProvider) : base(logger) { this.dateTimeProvider = dateTimeProvider; } public override void Debug(object message) { Logger.Log(createLoggingEvnet(Level.Debug, message)); } private LoggingEvent createLoggingEvnet(Level level, object message) { return new LoggingEvent( declaringType, Logger.Repository, createLoggingEventData(level, message)); } private LoggingEventData createLoggingEventData(Level level, object message) { return new LoggingEventData { Level = level, LoggerName = Logger.Name, Message = message.ToString(), TimeStamp = dateTimeProvider.Now }; } } The calling code might look something like this: // untested public static class LogManager2 { public static ILog GetLoggerT() { return new DateTimeProviderLogger(LogManager.GetLogger(typeof(T)).Logger, DateTimeProvider.DateTimeNow); } } // untested class Program { public static readonly ILog log = LogManager2.GetLoggerProgram(); } From: Ayrat Khalimov airat.hali...@gmail.com To: log4net-user@logging.apache.org Sent: Thu, November 12, 2009 7:49:13 AM Subject: precise time stamp Hi, there I need to log events with precise time stamps (more precise than 15 ms System.DateTime). But it seems to be impossible to do it with log4net. It is impossible to change default timer neither to implement special appender that will set precise value to TimeStamp. The only solution I see is to write precise time to the event message body. Any ideas, colleagues? -- Sincerely, Ayrat Khalimov.
Re: Debugging from Visual Studio 2005: log statements in dlls don't work
Can you post a small sample of your code that's failing? Are you able to configure a very simple ConsoleAppender to verify it isn't a configuration loading issue? [TestFixture] public class LoggingWithinVSDebuggerTestFixture { [Test] public void HelloWorldConsoleAppender() { var consoleAppender = new ConsoleAppender(); consoleAppender.Layout = new SimpleLayout(); BasicConfigurator.Configure(consoleAppender); LogManager.GetLogger(GetType()).Debug(Hello World); } } - Original Message From: SteveClay steve.c...@barclayscapital.com To: log4net-user@logging.apache.org Sent: Mon, October 12, 2009 6:09:27 AM Subject: Debugging from Visual Studio 2005: log statements in dlls don't work When debugging tests from Visual Studio 2005 the log statements in my dlls don't work. The test project has a config xml file with the log4net extension. Each test is prefixed with [TestMethod] and I use the right click 'Test with ...debugger' option. Then each dll has a statement like this in its AssemblyInfo.cs: [assembly: log4net.Config.XmlConfigurator(ConfigFileExtension = log4net, Watch = true)] A log file does get created but it just says 'Log file start' / Log file end' ..there are many log statements in the executed code which should write to the log. Please can someone tell me how can I configure VS or my test project or the other projects so that logging works when running in debug mode? -- View this message in context: http://www.nabble.com/Debugging-from-Visual-Studio-2005%3A-log-statements-in-dlls-don%27t-work-tp25853273p25853273.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Two assemblies using same Log4Net framework
The main application should configure log4net. The other libraries should just create logging statements. You don't need to pass the repository between applications. - Original Message From: Peter pete...@circle-consulting.co.nz To: log4net-user@logging.apache.org Sent: Thu, September 24, 2009 10:11:37 PM Subject: Two assemblies using same Log4Net framework Hi My main VB.NET application uses sets up and configures Log4Net. It calls two or three other assemblies and I want to pass a reference to the main app's Log4Net instance to those assemblies so they log messages into the same log file and respect the same configuration settings. Is it correct to do this: In the main app I have the following method call to my assembly: SetLog(mLog.Logger.Repository) Where mLog implements the ILog interface. In the assembly the SetLog method is: Public Sub SetLog(ByVal Repository As log4net.Repository.ILoggerRepository) log4net.Config.BasicConfigurator.Configure(Repository) mLog = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod ().DeclaringType) End Sub This seems to work OK but I'm unsure if it's a good thing to pass Repository's between assemblies in this way. Any and all advice would be appreciated.
Use the most recent LoggingEvent to dynamically set SmtpAppender.Subject
Someone on my team asked me how they could use a dynamic subject with SmtpAppender. Here's an example that uses a PatternLayout against the last LoggingEvent for the subhject: /// summary /// Formats the email subject using the supplied PatternLayout against the last email in the buffer. /// /summary public class LastEventSubjectSmtpAppender : SmtpAppender { private LoggingEvent _lastEvent; public PatternLayout LastEventSubject { get; set; } protected override void SendBuffer(LoggingEvent[] events) { _lastEvent = events[events.Length - 1]; base.SendBuffer(events); _lastEvent = null; } protected override void SendEmail(string messageBody) { using (var sw = new StringWriter()) { LastEventSubject.Format(sw, _lastEvent); Subject = sw.ToString(); } base.SendEmail(messageBody); } }
Setting SmtpAppender's body to the most recent LoggingEvent and attaching all other events
This places the most recent LoggingEvent in the email body and allows the subject to be set dynamically while still including the other messages in the buffer as an attachment. I've always wanted something like this and finally found time to write a first version. It could be improved to allow the attachment to be compressed. I didn't need all the fancy special header, footer, ssl, etc. support but its trivial to add that stuff back in: public class MailAttachmentSmtpAppender : SmtpAppender { public PatternLayout SubjectLayout { get; set; } protected override void SendBuffer(LoggingEvent[] events) { try { using (var stream = new MemoryStream()) { using (var writer = new StreamWriter(stream)) { for (int i = 0; i events.Length; i++) { RenderLoggingEvent(writer, events[i]); } writer.Flush(); stream.Seek(0, SeekOrigin.Begin); SendMail(events[events.Length - 1], stream); } } } catch (Exception e) { ErrorHandler.Error(Error occurred while sending e-mail notification., e); } } protected virtual void SendMail(LoggingEvent lastEvent, Stream renderedEvents) { SmtpClient smtpClient = new SmtpClient(SmtpHost); using (MailMessage mailMessage = new MailMessage()) { mailMessage.To.Add(To); mailMessage.From = new MailAddress(From); if (SubjectLayout != null) { using (var subjectWriter = new StringWriter()) { SubjectLayout.Format(subjectWriter, lastEvent); mailMessage.Subject = subjectWriter.ToString(); } } else { mailMessage.Subject = Subject; } mailMessage.Body = RenderLoggingEvent(lastEvent); mailMessage.Attachments.Add(new Attachment(renderedEvents, logs.txt, text/plain)); smtpClient.Send(mailMessage); } } }
Re: Experiencing locks while using AdoNetAppender
I think that's how SQLite works. Have you tried writing to a single .db file from multiple threads without using log4net? From: Patrick Kalkman p...@hoogendoorn.nl To: log4net-user@logging.apache.org Sent: Tuesday, August 18, 2009 8:29:17 AM Subject: Experiencing locks while using AdoNetAppender Experiencing locks while using AdoNetAppender Hi, I am using the AdoNetAppender for logging messages from multiple application. All the applications log into one sqllite database. Sometimes when a lot of information is logged I am experiencing exceptions like: log4net:ERROR [AdoNetAppender] Exception while writing to database System.Data.SQLite.SQLiteException: The database file is locked database is locked at System.Data.SQLite.SQLite3.Reset(SQLiteStatement stmt) at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt) at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery() at System.Data.SQLite.SQLiteTransaction..ctor(SQLiteConnection connection, Boolean deferredLock) at System.Data.SQLite.SQLiteConnection.BeginTransaction(Boolean deferredLock) at System.Data.SQLite.SQLiteConnection.BeginDbTransaction(IsolationLevel isolationLevel) at System.Data.Common.DbConnection.System.Data.IDbConnection.BeginTransaction() at log4net.Appender.AdoNetAppender.SendBuffer(LoggingEvent[] events) The default CommandTimeout in the AdoNetAppender on the IDbCommand is 30 seconds, but I would like to influence this timeout in the log4net configuration (file) so that I can influence the timeout on the logging if the database is locked for a longer portion of time. Reducing the timeout may lead to events getting lost, but I prefer that to our application hanging for the full CommandTimeout waiting for the database to become unlocked. Is it possible to configure the timeout using configuration? or would it be better to choose for a solution like deriving from the AdoNetAppender and add the functionality? Thanks in advance for any answers. Patrick **DISCLAIMER** Deze E-mail is uitsluitend bestemd voor de geadresseerde(n). Verstrekking aan en gebruik door anderen is niet toegestaan. De Hoogendoorn Groep sluit iedere aansprakelijkheid uit die voortvloeit uit elektronische verzending. This E-mail is intended exclusively for the addressee(s), and may not be passed on to, or made available for use by any person other than the addressee(s). The Hoogendoorn Group rules out any and every liability resulting from any electronic transmission. *** This message has been scanned by Network Associates' McAfee AntiVirus Technology
Re: Does log4net support 64-bit Windows environments?
What are the real issues you've found? - Original Message From: kjh_ngisd kjhsd_do...@yahoo.com To: log4net-user@logging.apache.org Sent: Monday, August 17, 2009 11:01:33 AM Subject: RE: Does log4net support 64-bit Windows environments? This post if from a while ago. Has log4net officially supported 64-bit OS's yet? Anyone know? I'm finding some real issues taking my stuff from 32 bit to 64. I've looked on log4net's site and can't see anything about it. I'm still debugging but it's looking more and more like log4net is the problem. Just wondering if anyone has any update on this. --kevin Susan Farley wrote: We've had it in use on our 64 bit machines for around 5 months with no problems; in case that helps. Susan From: jeroenbart.enge...@kpn.com [mailto:jeroenbart.enge...@kpn.com] Sent: Thursday, January 24, 2008 11:09 AM To: log4net-user@logging.apache.org Subject: RE: Does log4net support 64-bit Windows environments? Thanks :-) -- XML is like violence: if it doesn't solve your problem, you aren't using enough of it Jeroen-bart Engelen, Senior software engineer, KPN Wholesale Operations, Service Operations, Ontwikkeling, ISP Diensten Tel:+31(0)30 6588252 E-mail: jeroenbart.enge...@kpn.com From: Dean Fiala [mailto:dfi...@celadonlabs.com] Sent: Thursday, January 24, 2008 17:03 To: 'Log4NET User' Subject: RE: Does log4net support 64-bit Windows environments? That I have no answer for. If it breaks I'll let you know. :) From: jeroenbart.enge...@kpn.com [mailto:jeroenbart.enge...@kpn.com] Sent: Thursday, January 24, 2008 10:44 AM To: log4net-user@logging.apache.org Subject: RE: Does log4net support 64-bit Windows environments? Okay, so it works for you. But I want to know if it's officially supported and thoroughly tested. I just want to make sure it doesn't work for a while and then inexplicitly stops working because of some overflow due to the 64-bitness of the system. -- XML is like violence: if it doesn't solve your problem, you aren't using enough of it Jeroen-bart Engelen, Senior software engineer, KPN Wholesale Operations, Service Operations, Ontwikkeling, ISP Diensten Tel:+31(0)30 6588252 E-mail: jeroenbart.enge...@kpn.com From: Dean Fiala [mailto:dfi...@celadonlabs.com] Sent: Thursday, January 24, 2008 15:13 To: 'Log4NET User' Subject: RE: Does log4net support 64-bit Windows environments? I recently recompiled log4net to a 64-bit version. It compiled and ran without issue under the 64-bit website and service we created. The only compiler warnings generated were for obsolete method calls. Regards, Dean Fiala Chief Technology Officer Celadon Laboratories, Inc. http://www.celadonlabs.com From: jeroenbart.enge...@kpn.com [mailto:jeroenbart.enge...@kpn.com] Sent: Thursday, January 24, 2008 6:02 AM To: log4net-user@logging.apache.org Subject: Does log4net support 64-bit Windows environments? Hello, We are currently planning on moving our .NET applications from Windows 2003 Server 32-bits, to the Windows 2003 Server 64-bits platform and are investigating if our applications can handle the 32 extra bits. We use log4net in all of our applications and when looking through the source I saw a few DLL Imports which could cause a problem. I tried looking on the log4net website and searching with Google, but I didn't find an answer. Can anyone tell me if log4net is able to run in a full 64-bit environment? So not on the 32-bits WOW subsystem, but as a full 64-bits module. Thanks! -- XML is like violence: if it doesn't solve your problem, you aren't using enough of it Jeroen-bart Engelen, Senior software engineer, KPN Wholesale Operations, Service Operations, Ontwikkeling, ISP Diensten Tel:+31(0)30 6588252 E-mail: jeroenbart.enge...@kpn.com -- View this message in context: http://www.nabble.com/Does-log4net-support-64-bit-Windows-environments--tp15062814p25008398.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Can we write the data to Multiple log
Does this example help? ?xml version=1.0 encoding=utf-8 ? log4net appender name=SimpleLayoutFileAppender type=log4net.Appender.FileAppender file value=Logs\Simple.txt / layout type=log4net.Layout.SimpleLayout / /appender appender name=PatternLayoutFileAppender type=log4net.Appender.FileAppender file value=Logs\PatternLayout.txt / layout type=log4net.Layout.PatternLayout conversionPattern value=%5level %date (%logger:%line) - %message%newline / /layout /appender root appender-ref ref=SimpleLayoutFileAppender / appender-ref ref=PatternLayoutFileAppender / /root /log4net From: raghuram.raicho...@accenture.com raghuram.raicho...@accenture.com To: log4net-user@logging.apache.org Sent: Monday, August 17, 2009 4:16:42 AM Subject: Can we write the data to Multiple log Hi, I am using the Rolling File Appender, and in this I would like to write the exception raised to two different logs one with simple information and other with the complete information. In the config file I have two sections defining the paths. ?xml version=1.0 standalone=yes ? SYSTEMINFORMATION SYSTEMIDDIS/SYSTEMID ERRORCODELISTPATH/config/errorCode.xml/ERRORCODELISTPATH /SYSTEMINFORMATION APPENDER MODE=tivoli NAME=RollingLogFileAppender TYPE=log4net.Appender.RollingFileAppender FILENAME VALUE=d://svr_app_prod//logs//app_logs//diss//tivoli.log / APPENDTOFILE VALUE=true / ROLLINGSTYLE VALUE=Size / MAXROLLBACKUPSIZE VALUE=10 / MAXFILESIZE VALUE=10MB / MAXENTRIESPERSECOND VALUE=10 / STATICLOGFILENAME VALUE=true / LAYOUT TYPE=log4net.Layout.PatternLayout CONVERSIONPATTERN VALUE=%date [%thread] %-5level %logger [%property{ndc}] - %message%newline / /LAYOUT /APPENDER APPENDER MODE=application NAME=RollingLogFileAppender TYPE=log4net.Appender.RollingFileAppender FILENAME VALUE=d://svr_app_prod//logs//app_logs//diss//application.log / APPENDTOFILE VALUE=true / ROLLINGSTYLE VALUE=Size / MAXROLLBACKUPSIZE VALUE=50 / MAXFILESIZE VALUE=50MB / MAXENTRIESPERSECOND VALUE=10 / STATICLOGFILENAME VALUE=true / LAYOUT TYPE=log4net.Layout.PatternLayout CONVERSIONPATTERN VALUE=%date [%thread] %-5level %logger [%property{ndc}] - %message%newline / /LAYOUT /APPENDER /DataSetConfiguration In our application we only mention Log.Debug(“Logging Information”). Could you please tell me how to specify the details of the log file. Regards, Raghuram Raichooti This message is for the designated recipient only and may contain privileged, proprietary, or otherwise private information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the email by you is prohibited.
Re: Adding custom logging properties
public class LogManager { public static GetLoggerT() { return new LogEx(LogManager.GetLogger(typeof(T))); } } // untested...I think I'm forgetting a constructor public class LogEx : LogImpl { private readonly static Type declaringType = typeof(LogEx); public void Info(string message, IDictionary properties) { if (IsInfoEnabled) { LoggingEvent loggingEvent = new LoggingEvent( declaringType, Logger.Repository, Logger.Name, Level.Info, message, t); foreach (var entry in properites) { loggingEvent.Properties[entry.Key.ToString()] = entry.Value; } Logger.Log(loggingEvent); } } } http://www.mail-archive.com/log4net-user@logging.apache.org/msg04357.html - Original Message From: AdamTappis adamtap...@hotmail.com To: log4net-user@logging.apache.org Sent: Monday, August 17, 2009 11:08:44 AM Subject: Re: Adding custom logging properties Having a closer look at the documentation, the Properties property of the LoggingEvent class is a PropertiesDictionary which derives from ReadOnlyPropertiesDictionary which menas it can't be written to and hence it's not suitable for my purposes. Any ideas? AdamTappis wrote: Ross, I guess that's why I'm posting here, because I'm trying to devise a pattern and some coding guidelines so that all our applications log consistently. I considered wrapping log4net but all I've read advises against that. So what I'm trying to achieve is an elegant solution that makes the best use of the framework. You're right, I wish to log a collection of Key-Value pairs associated with a given loggin event. e.g. statistics - eventDataduration3ms/durationsize10kb/size/eventData details - eventDatacustomerID3/customerIDorderID10/orderID/eventData The question I'm asking is how best to implement this with log4net? Should I write a wrapper or a helper class that accepts the key-Value pairs collection as a parameter and returns a formattred XML string that then get's logged? Maybe I should be creating a LoggingEvent in code manually, adding the Key-Value pairs to the Properties collection and then using ILog.Logger.Log to actually log the event rather than using Ilog.Info() to log. I could than write a custom layout class that serialises the properties out as an XML string. like I said, I'm not sure and am looking for some disrection. Ideally I would have the following interface available to me: ILog.Info(string message, Dictionary customProperties) and then it would be the configuration that drives how the customProperties are rendered by specifying the approporiate Layout class. That way I could format the customProperties to a file in one way and to a Db as XML etc... without embedding the formatting logic in my code. Ross Hinkley wrote: Adam, How are these properties getting transformed from a logging call to XML? Are you asking if there's a way to modify a custom format on the fly and then turn the custom properties into XML? (I'm thinking of something like appending name-value pairs to the log format and having a custom appender do the XML conversion for you. This doesn't seem terribly elegant.) Maybe I'm over-trivializing, but it seems to me you should be able to use custom properties to take care of your current needs, converting your properties to XML in code, then modifying the ADO appender configuration to handle that property appropriately when the logging database is implemented. I guess another question would be what sorts of things need to be serialized? Are they going to be serialized from a class? -Ross On Mon, Aug 17, 2009 at 8:12 AM, AdamTappis adamtap...@hotmail.com wrote: Hi, I've been evaluating log4net recently with a view to using the framework as a loggin standard for our enterprise applicaption. I see it very easy to extend the framework, however I have some specific logging requirements and I'm not sure what would be the easiest way implement these with minimal coding. At some time in the future, we aim to build a consolidated logging database that will capture logging data from our server application suite. The information that needs to be logged will differ per service/applicaption and to that end I would aim to have a table schema that has the standard logging columns plus a generic XML column (no defined schema) to act as a property bag for custom information associated with a specific event. We don't have time to develop the logging repository at present, however I'm stressing that we should build logging into our code from the start rather than trying to retro-fitting it later which would be far more costly. So I need my code to be able to fire off logging messages with a list or arbitrary custom properties that get formatted into an XML string. For now the messages can be written to a text file and later we'll configure and AdoNetAppender to write to out logging database. So my
Re: Location of logs when FileAppender can't open a file
If a logger can't write to its destination it will notify its ErrorHandler and go offline. You should be able to bring it back online by resetting its ErrorHandler and calling ActivateOptions. I don't have the source in front of me so I can't give a concrete example. From: Pedro Checo pch...@pacificsummitenergy.com To: log4net-user@logging.apache.org log4net-user@logging.apache.org Sent: Monday, July 27, 2009 11:15:08 AM Subject: Location of logs when FileAppender can't open a file Hi. Suppose that a FileAppender in use is set to log to a directory for which it has no write or create rights, what will it do, where will the log files be created? We have a situation where, depending on the user, the process that owns the log4net logger instance will not be able to write to the designated directory for the FileAppender. In later versions of the application, we may resolve this before log4net is initialized, but our current version doesn’t have that ability at present. Regards and thank you for publishing this comprehensive library. Regards.
Re: Error while sending Mail to smtp.gmail.com
My suggestion would be to get email sending working using SmtpClient. There's nothing wrong with writing your own Appender. Here's one that I use for sending low volume ERROR and FATAL messages in a Medium Trust hosting environment: public class MediumTrustSmtpAppender : AppenderSkeleton { public string From { get; set;} public string To { get; set;} public string Subject { get; set;} public string Host { get; set;} protected override void Append(LoggingEvent loggingEvent) { MailMessage mailMessage = new MailMessage(From, To, Subject, RenderLoggingEvent(loggingEvent)); SmtpClient smtpClient = new SmtpClient(Host); smtpClient.Send(mailMessage); } } From: Sree sree.opt...@gmail.com To: Log4NET User log4net-user@logging.apache.org Sent: Tuesday, July 21, 2009 6:30:42 AM Subject: RE: Error while sending Mail to smtp.gmail.com I’ve disabled the windows firewall also the antivirus software but sill got the below error…no change… L Best regards, Sree From:Radovan Raszka [mailto:ras...@hasam.cz] Sent: Tuesday, July 21, 2009 3:22 PM To: Log4NET User Subject: RE: Error while sending Mail to smtp.gmail.com One more idea - is there any antivirus / firewall software on the computer you are doing your tests? It can block communication - I had to switch outgoing mail checking off somewhere in the past RR Od:Sree [mailto:sree.opt...@gmail.com] Odesláno: 21. července 2009 11:02 Komu: ' Log4NET User ' Předmět: RE: Error while sending Mail to smtp.gmail.com But I’m getting error: A first chance exception of type 'System.InvalidOperationException' occurred in log4netTests.exe log4net:ERROR [SmtpAppender] Error occurred while sending e-mail notification. System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first. 22sm14461822wfd.8 at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response) at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, String from) at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException exception) at System.Net.Mail.SmtpClient.Send(MailMessage message) at log4net.Appender.SmtpAppender.SendEmail(String messageBody) at log4net.Appender.SmtpAppender.SendBuffer(LoggingEvent[] events) Do I need to do any other specific settings.. Please help me out…and I really Thank for ur responses… Best regards, Sree From:Radovan Raszka [mailto:ras...@hasam.cz] Sent: Tuesday, July 21, 2009 1:15 AM To: Log4NET User Subject: RE: Error while sending Mail to smtp.gmail.com Works for me without any configuration exception. I had only to change port to 25, why you are trying 465? My config: appendername=SmtpAppendertype=log4net.Appender.SmtpAppender tovalue=ras...@hasam.cz/ fromvalue=myusern...@gmail.com / subjectvalue=test logging message/ smtpHostvalue=smtp.gmail.com/ authenticationvalue= Basic/ usernamevalue= username/ passwordvalue= mypassword/ enablesslvalue=true/ portvalue=25/ bufferSizevalue=512/ lossyvalue=false/ evaluatortype=log4net.Core.LevelEvaluator thresholdvalue=ALL/ /evaluator layouttype=log4net.Layout.PatternLayout conversionPatternvalue=%newline%date [%thread] %-5level %logger [%property{NDC}] - %message%newline%newline%newline/ /layout /appender RR Od:Sree [mailto:sree.opt...@gmail.com] Odesláno: 20. července 2009 9:50 Komu: ' Log4NET User ' Předmět: RE: Error while sending Mail to smtp.gmail.com No this also didn’t work out… From:Radovan Raszka [mailto:ras...@hasam.cz] Sent: Friday, July 17, 2009 4:53 PM To: Log4NET User Subject: RE: Error while sending Mail to smtp.gmail.com strange, this property exists in source code taken from source repository. But doesn't exist in binary distribution (even there is no ssl property!), so try to get current sources from repository, compile and try again Radovan Od:Sree [mailto:sree.opt...@gmail.com] Odesláno: 17. července 2009 13:09 Komu: ' Log4NET User ' Předmět: RE: Error while sending Mail to smtp.gmail.com log4net:ERROR XmlHierarchyConfigurator: Cannot find Property [enablessl] to set object on [log4net.Appender.SmtpAppender] getting the above error Best regards, Sree
Re: How to make a part of log message uppercase
This should work: // untested public class HostNameToUpperLayout : LayoutSkeleton { public override void ActivateOptions() { // empty } public override void Format(TextWriter writer, LoggingEvent loggingEvent) { string hostName = (string)loggingEvent.LookupProperty(log4net:HostName); writer.Write(hostName.ToUpper()); } } parameter parameterName value=@message/ dbType value=String/ size value=4000/ layout type=Company.Application.HostNameToUpperLayout, Company.Application / /parameter There are more clever ways of doing it but that should work. From: Cankut Eskin cankutes...@gmail.com To: Log4NET User log4net-user@logging.apache.org Sent: Monday, June 22, 2009 9:09:37 AM Subject: How to make a part of log message uppercase Hello, I'm using AdoNetAppender to log messages. I've added %property{log4net:HostName} conversion pattern to the message parameter. parameter parameterName value=@message/ dbType value=String/ size value=4000/ layout type=log4net.Layout.PatternLayout conversionPattern value=[%property{log4net:HostName}] - %message/ /layout /parameter Output is like [hostname] - foo bar. But i want the output like [HOSTNAME] - foo bar. How can i make the hostname uppercase using conversion patterns? Regards, Cankut
Re: unsubscribe
I think you need to send an email to a special unsubscribe address, not just a subject with unsubscribe as the subject. - Original Message From: Laurence Hunter cazador7...@yahoo.com To: Log4NET User log4net-user@logging.apache.org Sent: Friday, June 19, 2009 12:51:17 PM Subject: unsubscribe unsubscribe
Re: Getting AdoNetAppender parameters using Log4Net API
Surprisingly the parameters collection isn't exposed publicly so you'd have to extend the built-in AdoNetAppender and expose them: public class AdoNetAppender2 : AdoNetAppender { public AdoNetAppenderParameter[] GetParameters() { return m_parameters.CastAdoNetAppenderParameter().ToArray(); } } Then you can ask the repository for all the AdoNetAppender2 appenders and inspect their values: var repository = LogManager.GetRepository(); foreach (var appender in repository.GetAppenders()) { var adoNetAppender = appender as AdoNetAppender2; if (adoNetAppender != null) { foreach (var parameter in adoNetAppender.GetParameters()) { // parameter.ParameterName; } } } From: Cankut Eskin cankutes...@gmail.com To: Log4NET User log4net-user@logging.apache.org Sent: Friday, June 19, 2009 1:13:13 PM Subject: Getting AdoNetAppender parameters using Log4Net API Hello, I've defined some extra parameters for AdoNetAppender in log4net config file. Everything works fine. Here is one of my extra parameters defined: parameter parameterName value=@cachetid/ dbType value=String/ size value=36/ layout type=log4net.Layout.RawPropertyLayout key value=CachetID/ /layout /parameter I wonder if there is some way in Log4Net API to get information about the parameters defined for AdoNetAppender in the config file. Any help will be appreciated. Regards, Cankut
Re: Log4net: context only for exception
You can make two different appenders: one that handles DEBUG statements and one that handles ERROR and higher messages or you could change the layout based on the level of the message: layout type=ConsoleApplication1.LevelPatternLayout, ConsoleApplication1 levelConversionPattern level value=DEBUG / conversionPattern value=%level - %message%newline / /levelConversionPattern levelConversionPattern level value=ERROR / conversionPattern value=%level - %logger - %property{ErrorUserId} - %message%newline / /levelConversionPattern /layout public class LevelPatternLayout : PatternLayout { private readonly Hashtable m_levelToPatternLayout = new Hashtable(); public override void Format(TextWriter writer, LoggingEvent loggingEvent) { var patternLayout = m_levelToPatternLayout[loggingEvent.Level] as PatternLayout; if (patternLayout == null) { base.Format(writer, loggingEvent); } else { patternLayout.Format(writer, loggingEvent); } } public void AddLevelConversionPattern(LevelConversionPattern levelLayout) { m_levelToPatternLayout[levelLayout.Level] = new PatternLayout(levelLayout.ConversionPattern); } } public class LevelConversionPattern { public Level Level { get; set; } public string ConversionPattern { get; set; } } - Original Message From: koger kars...@f-kousgaard.dk To: log4net-user@logging.apache.org Sent: Thursday, June 18, 2009 8:27:26 AM Subject: Log4net: context only for exception Hi I also posted this question at http://stackoverflow.com/questions/1011730/log4net-context-only-for-exception http://stackoverflow.com/questions/1011730/log4net-context-only-for-exception . But I think this might be a better place. Here is the question: I'm looking for a way to collect a set of data, that will only be used for debugging, the data should only be logged if I log an exception. AFAIK it can happend when ILog.Error, Fatal or Debug with an exception argument when logging other data with an exception, the data shouldn't be logged. I plan to use the GlobalContext or ThreadContext for building the dataset. My idea was to hook into Log4Net and attach to an event I would imagine, to alter the message pattern to include contexts. But I can't find any event that would help me, perhaps there also might be a easier way? What do you think about the overall design of this, am I on the right track or am I missing something? If this way is good, how can I implement it? -- View this message in context: http://www.nabble.com/Log4net%3A-context-only-for-exception-tp24091804p24091804.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Mystery concerning configuration
WorksOnMyMachine class Program { static void Main(string[] args) { LogLog.InternalDebugging = true; LogLog.EmitInternalMessages = true; XmlDocument log4netConfig = new XmlDocument(); log4netConfig.LoadXml(@ log4net appender name='LogServiceAppender' type='log4net.Appender.RollingFileAppender' file value='c:\\LogServiceAppender.log' / appendToFile value='true'/ maxSizeRollBackups value='10'/ maximumFileSize value='1MB'/ rollingStyle value='Size'/ staticLogFileName value='true'/ layout type='log4net.Layout.PatternLayout' conversionPattern value='%d{ MMM dd HH:mm:ss} [%t] %-5p - %m%n' / /layout /appender root level value='ALL' / appender-ref ref='LogServiceAppender' / /root /log4net); ILoggerRepository rep = LogManager.CreateRepository(Guid.NewGuid().ToString()); XmlConfigurator.Configure(rep, log4netConfig[log4net]); ILog log = LogManager.GetLogger(rep.Name, Program); log.Debug(Hello World); } } From: Eric Chamberlain eric.chamberl...@stratagen.com To: log4net-user@logging.apache.org Sent: Thursday, June 18, 2009 6:41:51 PM Subject: Mystery concerning configuration Greetings all, I have an appender which works fine if specified with generic XML but not when specified with conventional log4net terms in the configuration. Examples should help: The following works: appendername=LogServiceAppender type=log4net.Appender.RollingFileAppender paramname=File value=myfile.log/ paramname=AppendToFile value=true/ paramname=MaxSizeRollBackups value=10/ paramname=MaximumFileSize value=1MB/ paramname=RollingStyle value=Size/ paramname=StaticLogFileName value=true/ layouttype=log4net.Layout.PatternLayout paramname=ConversionPattern value=%d{ MMM dd HH:mm:ss} [%t] %-5p - %m%n/ /layout /appender But the following does *not* work. It fails to initialize (I turned on the log4net debugging to see it). appendername=LogServiceAppender type=log4net.Appender.RollingFileAppender filevalue=myfile.log/ appendToFilevalue=true/ maxSizeRollBackupsvalue=10/ maximumFileSizevalue=1MB/ rollingStylevalue=Size/ staticLogFileNamevalue=true/ layouttype=log4net.Layout.PatternLayout conversionPatternvalue=%d{ MMM dd HH:mm:ss} [%t] %-5p - %m%n/ /layout /appender It appears that log4net initialization does not recognized its own XML schema. How is that possible? __ Eric Chamberlain
Re: Deleting old logs
Hopefully you glanced at the public properties on RollingFileAppender and realized that the property is actually called RollingStyle: RollingStyle value=Size / - Original Message From: M.Suarez moc...@gmail.com To: log4net-user@logging.apache.org Sent: Thursday, June 18, 2009 4:53:45 PM Subject: Re: Deleting old logs I have just checked and this is what happened: log4net:ERROR XmlHierarchyConfigurator: Cannot find Property [RollingMode] to se t object on [log4net.Appender.RollingFileAppender] Ron Grabowski wrote: What happens when you add RollingMode value=Size /? http://logging.apache.org/log4net/release/config-examples.html - Original Message From: M.Suarez moc...@gmail.com To: log4net-user@logging.apache.org Sent: Monday, June 15, 2009 5:21:24 PM Subject: Deleting old logs Hi, I am trying to just have the latest 2 log files of my application, thus I have configured the log4net as follows: log4net appender name=RollingFile type=log4net.Appender.RollingFileAppender file value=d:\netapps\logfiles\MyApp.log / appendToFile value=true / MaximumFileSize value=100KB/ MaxSizeRollBackups value=2 / lockingModel type=log4net.Appender.FileAppender+MinimalLock / layout type=log4net.Layout.PatternLayout conversionPattern value=%date [%thread] %-5level %logger - %message%newline / /layout /appender !-- Set root logger level to INFO and its only appender to Console and RollingFile-- root level value=INFO / appender-ref ref=RollingFile / /root /log4net However, there will be more than then two expected log files, this is because: The maximum applies to each time based group of files and not the total (http://logging.apache.org/log4net/release/sdk/log4net.Appender.RollingFileAppender.MaxSizeRollBackups.html) How should I configure log4net then to only store the latest two files? Any help will be greatly appreciate it. Regards, Monica -- View this message in context: http://www.nabble.com/Deleting-old-logs-tp24042093p24042093.html Sent from the Log4net - Users mailing list archive at Nabble.com. -- View this message in context: http://www.nabble.com/Deleting-old-logs-tp24042093p24099615.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Deleting old logs
While this might not be the exact answer you were looking for, don't forget that sometimes its easier to just write the 3 lines of code yourself for deleting old log files and move on to other things: foreach (string file in Directory.GetFiles(c:\\logs, *.log)) { if (DateTime.Today.Subtract(File.GetLastWriteTime(file)).Days 10) { File.Delete(file); } } - Original Message From: M.Suarez moc...@gmail.com To: log4net-user@logging.apache.org Sent: Monday, June 15, 2009 5:21:24 PM Subject: Deleting old logs Hi, I am trying to just have the latest 2 log files of my application, thus I have configured the log4net as follows: log4net appender name=RollingFile type=log4net.Appender.RollingFileAppender file value=d:\netapps\logfiles\MyApp.log / appendToFile value=true / MaximumFileSize value=100KB/ MaxSizeRollBackups value=2 / lockingModel type=log4net.Appender.FileAppender+MinimalLock / layout type=log4net.Layout.PatternLayout conversionPattern value=%date [%thread] %-5level %logger - %message%newline / /layout /appender !-- Set root logger level to INFO and its only appender to Console and RollingFile-- root level value=INFO / appender-ref ref=RollingFile / /root /log4net However, there will be more than then two expected log files, this is because: The maximum applies to each time based group of files and not the total (http://logging.apache.org/log4net/release/sdk/log4net.Appender.RollingFileAppender.MaxSizeRollBackups.html) How should I configure log4net then to only store the latest two files? Any help will be greatly appreciate it. Regards, Monica -- View this message in context: http://www.nabble.com/Deleting-old-logs-tp24042093p24042093.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Using AdoNetAppender
Its quite difficult to document every possible usage of a library. In addition to these documents: http://logging.apache.org/log4net/release/config-examples.html http://logging.apache.org/log4net/release/sdk/log4net.Appender.AdoNetAppender.html http://logging.apache.org/log4net/release/sdk/log4net.Appender.AdoNetAppenderParameter.Layout.html There's about 8,000 search results on Google for AdoNetAppender. A lot of the documentation is focused on XML examples because that's how the majority of the users configure log4net. I'll glady add your code configuration examples to AdoNetAppenderTest.cs if attach them to a JIRA ticket! From: James Green james.gr...@occam-dm.com To: Log4NET User log4net-user@logging.apache.org Sent: Tuesday, June 16, 2009 4:48:27 AM Subject: RE: Using AdoNetAppender Hi Again, Surely, this is all pointing to a far bigger problem. That is an horrific piece of code!! Surely this is doable in pure C#? I'm amazed that this AdoNetAppender is so poorly documented and has so few examples. It's starting to put me off log4net! James. From: Ron Grabowski [mailto:rongrabow...@yahoo.com] Sent: 15 June 2009 22:32 To: Log4NET User Subject: Re: Using AdoNetAppender This page shows an example of loading an xml string into an XmlDocument then configure log4net from the XmlDocument: http://svn.apache.org/viewvc/logging/log4net/trunk/tests/src/Appender/AdoNetAppenderTest.cs?view=co From: James Green james.gr...@occam-dm.com To: Log4NET User log4net-user@logging.apache.org Sent: Monday, June 15, 2009 12:04:16 PM Subject: RE: Using AdoNetAppender I think I'm going to have to try the config file method first. I'm wrapping log4net and I don't want to cause every consuming component to require loads of config information in it just for logging purposes. Everything else is a sinch to configure in code, save for this appender ... *sigh* ... Cheers, James. scanned by MessageLabs [www.messagelabs.com]
Re: Deleting old logs
What happens when you add RollingMode value=Size /? http://logging.apache.org/log4net/release/config-examples.html - Original Message From: M.Suarez moc...@gmail.com To: log4net-user@logging.apache.org Sent: Monday, June 15, 2009 5:21:24 PM Subject: Deleting old logs Hi, I am trying to just have the latest 2 log files of my application, thus I have configured the log4net as follows: log4net appender name=RollingFile type=log4net.Appender.RollingFileAppender file value=d:\netapps\logfiles\MyApp.log / appendToFile value=true / MaximumFileSize value=100KB/ MaxSizeRollBackups value=2 / lockingModel type=log4net.Appender.FileAppender+MinimalLock / layout type=log4net.Layout.PatternLayout conversionPattern value=%date [%thread] %-5level %logger - %message%newline / /layout /appender !-- Set root logger level to INFO and its only appender to Console and RollingFile-- root level value=INFO / appender-ref ref=RollingFile / /root /log4net However, there will be more than then two expected log files, this is because: The maximum applies to each time based group of files and not the total (http://logging.apache.org/log4net/release/sdk/log4net.Appender.RollingFileAppender.MaxSizeRollBackups.html) How should I configure log4net then to only store the latest two files? Any help will be greatly appreciate it. Regards, Monica -- View this message in context: http://www.nabble.com/Deleting-old-logs-tp24042093p24042093.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Using AdoNetAppender
You could have also copied the built-in TimeStamp layout // log4net.Layout public class RawTimeStampLayout : IRawLayout { public object Format(LoggingEvent loggingEvent) { return loggingEvent.TimeStamp; } } and made your own Level layout: public class RawLevelLayout : IRawLayout { public object Format(LoggingEvent loggingEvent) { return loggingEvent.Level; } } - Original Message From: James Green james.gr...@occam-dm.com To: Log4NET User log4net-user@logging.apache.org Sent: Tuesday, June 16, 2009 5:58:12 AM Subject: RE: Using AdoNetAppender Cracked it ... AdoNetAppenderParameter logLevel = new AdoNetAppenderParameter(); logLevel.ParameterName = @log_level; logLevel.Layout = new Layout2RawLayoutAdapter(new PatternLayout(%level)); logLevel.Size = 50; logLevel.DbType = System.Data.DbType.String; _sqlDatabaseAppender.AddParameter(logLevel); Regards, James.
Re: Using AdoNetAppender
If you don't specify a ConnectionType AdoNetAppender defaults to using OleDbConnection which has a different connection string format than the more common SqlConnection. Are you sure you want to use OleDbConnection? Why not write a simple ConsoleApplication to test your code and look at the configuration output log4net writes to Console.Out? class Program { private static AdoNetAppender _sqlDatabaseAppender = new AdoNetAppender(); static void Main(string[] args) { LogLog.InternalDebugging = true; LogLog.EmitInternalMessages = true; ConfigureDatabaseAppender(...); ILog log = LogManager.GetLogger(typeof(Program)); log.Debug(Hello World); Console.ReadLine(); } public static void ConfigureDatabaseAppender(string connString) { // snip From: James Green james.gr...@occam-dm.com To: Log4NET User log4net-user@logging.apache.org Sent: Monday, June 15, 2009 12:04:16 PM Subject: RE: Using AdoNetAppender I think I'm going to have to try the config file method first. I'm wrapping log4net and I don't want to cause every consuming component to require loads of config information in it just for logging purposes. Everything else is a sinch to configure in code, save for this appender ... *sigh* ... Cheers, James.
Re: How do I use dynamic boolean values on RollingFileAppender
This had me stumped for a while. My initial thought was to subclass FileAppender or RollingFileAppender and override ActivateOptions. You can't do that because the error happens during the XML configuration processing. What you need to do is write a PatternString to Boolean adapter for the XML processor: public class PatternStringToBooleanAdapter : IConvertTo { public string ConversionPattern { get; set; } public bool CanConvertTo(Type targetType) { return targetType == typeof(bool); } public object ConvertTo(object source, Type targetType) { var patternStringToBooleanAdapter = (PatternStringToBooleanAdapter)source; var patternString = new PatternString(patternStringToBooleanAdapter.ConversionPattern); string value = patternString.Format(); return OptionConverter.ToBoolean(value, false); } } Register it before you process the xml file: ConverterRegistry.AddConverter(typeof(PatternStringToBooleanAdapter), new PatternStringToBooleanAdapter()); GlobalContext.Properties[AppendToFile] = true; log4net.Config.XmlConfigurator.Configure(); Then tell the XML processor that you want to intercept the normal property setting with your adapter: appender name=FileAppender type=log4net.Appender.FileAppender file value=log.txt / appendToFile type=ConsoleApplication1.PatternStringToBooleanAdapter, ConsoleApplication1 conversionPattern value=%property{AppendToFile} / /appendToFile layout type=log4net.Layout.SimpleLayout / /appender From: Richard Fouts rfo...@we-are-it.com To: log4net-user@logging.apache.org; log4net-...@logging.apache.org Sent: Friday, June 5, 2009 11:01:18 AM Subject: How do I use dynamic boolean values on RollingFileAppender I have ran into a small brick wall. Hoping that I can find a couple of log4net guru's here. My situation. In trying to make my logging as configurable as possible in my application, I have been tinkering with trying to set the boolean values for appendToFile and staticLogFileName as dynamic values. These have a default value (currently stored in the My.Settings metadata). My problem is that when I go to configure the values at runtime I get this error in my stack trace: log4net:ERROR XmlHierarchyConfigurator: Could not create Appender [SyncLogFile] of type [log4net.Appender.RollingFileAppender]. Reported error follows. System.FormatException: String was not recognized as a valid Boolean. at System.Boolean.Parse(String value) at log4net.Util.TypeConverters.BooleanConverter.ConvertFrom(Object source) at log4net.Util.OptionConverter.ConvertStringTo(Type target, String txt) at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ConvertStringTo(Type type, String value) at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.SetParameter(XmlElement element, Object target) at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement appenderElement) log4net:ERROR XmlHierarchyConfigurator: Appender named [SyncLogFile] not found. log4net:ERROR XmlHierarchyConfigurator: Could not create Appender [ErrLogFile] of type [log4net.Appender.FileAppender]. Reported error follows. System.FormatException: String was not recognized as a valid Boolean. at System.Boolean.Parse(String value) at log4net.Util.TypeConverters.BooleanConverter.ConvertFrom(Object source) at log4net.Util.OptionConverter.ConvertStringTo(Type target, String txt) at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ConvertStringTo(Type type, String value) at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.SetParameter(XmlElement element, Object target) at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement appenderElement) log4net:ERROR XmlHierarchyConfigurator: Appender named [ErrLogFile] not found. log4net:ERROR XmlHierarchyConfigurator: Could not create Appender [SyncLogFile] of type [log4net.Appender.RollingFileAppender]. Reported error follows. System.FormatException: String was not recognized as a valid Boolean. at System.Boolean.Parse(String value) at log4net.Util.TypeConverters.BooleanConverter.ConvertFrom(Object source) at log4net.Util.OptionConverter.ConvertStringTo(Type target, String txt) at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ConvertStringTo(Type type, String value) at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.SetParameter(XmlElement element, Object target) at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement appenderElement) log4net:ERROR XmlHierarchyConfigurator: Appender named [SyncLogFile] not found. log4net:ERROR XmlHierarchyConfigurator: Could not create Appender [ErrLogFile] of type [log4net.Appender.FileAppender]. Reported error follows. System.FormatException: String was not recognized as a valid Boolean. at System.Boolean.Parse(String value) at
Re: Key cannot be null error
Are you sure you're providing a valid connection string property? The latest source code contains this code: // Sadly, your connection string is bad. ErrorHandler.Error(Could not open database connection [ + resolvedConnectionString + ]. Connection string context [ + connectionStringContext + ]., e); which seems to match your error message. Can you paste your appender node to the list? From: Gary Cooper lewd_revel...@yahoo.co.uk To: Log4NET User log4net-user@logging.apache.org Sent: Thursday, May 21, 2009 4:57:14 PM Subject: Re: Key cannot be null error Thanks for your replies Karim Radovan. I have attempted to track down the problem with the log4net source, but this doesnt seem to have yielded much success. I am thinking that this could possibly be an error with MySql connector as opposed to log4net, after all this doesnt seem to be happening with SQL Server or Oracle (or at least it isnt being reported). Karim, I think I followed your example on DevShed concerning this setup, I would like to thankyou for putting that together and I look forward to reading your blog article on this, I hope one of us will be able to overcome this problem - unfortunately, I dont have access to another DB to test this out on, but it would be nice to hear back from someone using the same code with Oracle or SQL Server. From: Karim Bourouba kar...@hotmail.com To: log4net-user@logging.apache.org Sent: Thursday, 21 May, 2009 11:52:56 Subject: RE: Key cannot be null error Hi Radovan, thats a great idea, I will give it a go and report back. Many thanks Subject: RE: Key cannot be null error Date: Thu, 21 May 2009 12:43:15 +0200 From: ras...@hasam.cz To: log4net-user@logging.apache.org Hello, you can try this: download log4net sources and attach them to your project instead of reference to log4net.dll. Now you'll be able to debug inside of AdonetAppender and you can find what exactly is null and guess the correct value, I hope. Radovan Raszka Od: Karim Bourouba [mailto:kar...@hotmail.com] Odesláno: 21. května 2009 10:43 Komu: log4net-user@logging.apache.org Předmět: RE: Key cannot be null error Hi Gary, I am actually having the same problem as you - I think. I definitely get the same error as you. Can I ask if you are using MySql at all? Unfortunately though, I havent had any luck with asking this question on this list, it would appear that the list is not as busy as I thought it initially was, or the other subscribers are unable to comment. To help you with your problem, if it isnt the same as mine, would be to post your code on the list itself. That gives everyone the chance to take a look and see if they can spot the issue. If you do have the same problem as me, could you post your solution should you fix it? That way others, including myself will be able to resolve this in future. Date: Wed, 20 May 2009 22:02:14 + From: lewd_revel...@yahoo.co.uk Subject: Key cannot be null error To: log4net-user@logging.apache.org Hello, Could someone explain to me what the following error means please? log4net:ERROR [AdoNetAppender] Could not open database connection [] System.ArgumentNullException: Key cannot be null. Parameter name: key I encounter this error when trying to log to my database. The rows are updated, but I get this message pop up on the console. I dont know how busy this list is, but I would really appreciate it if someone could lend a hand. TIA Share your photos with Windows Live Photos - Free. Try it Now! Windows Live Messenger just got better. Find out more!
Re: Strange Syste.ArgumentNullException
Looks like the MySql connection pool is loosing the connection string. What version of the mysql provider are you using? From: Karim Bourouba kar...@hotmail.com To: log4net-user@logging.apache.org Sent: Wednesday, May 20, 2009 11:57:24 AM Subject: Strange Syste.ArgumentNullException Hi All, I am getting a strange System.ArgumentNullException when using a AdoNetAppender. The message I am passing is is caught and logged to the DB, but on the console I am getting the following error: log4net:ERROR [AdoNetAppender] Could not open database connection [] System.ArgumentNullException: Key cannot be null. Parameter name: key at System.Collections.Hashtable.get_Item(Object key) at MySql.Data.MySqlClient.MySqlPoolManager.GetPool(MySqlConnectionStringBuilder settings) at MySql.Data.MySqlClient.MySqlConnection.Open() at log4net.Appender.AdoNetAppender.InitializeDatabaseConnection() I have checked my app.config, but I am unsure as to where this error is coming from and I am also unsure as to why the message I am trying to log is getting logged to my DB. Could someone help me out please? I am certain that someone on this list will be able to give me a clue as to where to start looking... Get the New Internet Explore 8 Optimised for MSN. Download Now
Re: Error destroying my productivity Please Help!: log4net:ERROR [] Attempted to append to closed appender named []
Ross' writeup is correct. This is not the correct way to define a logger: logger name=Invoicing level value=DEBUG / appender-ref ref=AdoNetAppender / /logger !-- WRONG -- logger name=Invoicing level value=FATAL / appender-ref ref=FileAppender / /logger That's the not the documented way to define loggers so I'd say that behavior is undefined...in this case it throws an exception that can probably be guarded against fairly easily. From: Ross Hinkley rosshink...@gmail.com To: Log4NET User log4net-user@logging.apache.org Sent: Wednesday, April 8, 2009 12:07:37 PM Subject: Re: Error destroying my productivity Please Help!: log4net:ERROR [] Attempted to append to closed appender named [] Omatase, What you want would be something like the following (I'm guessing): log4net debug=false threshold=ALL appender name=WarningAppender type=log4net.Appender.ConsoleAppender threshold value=WARN/ layout type=log4net.Layout.PatternLayout conversionPattern value=[WarningAppender] - %message%newline / /layout /appender appender name=InfoAppender type=log4net.Appender.ConsoleAppender threshold value=INFO/ layout type=log4net.Layout.PatternLayout conversionPattern value=[InfoAppender] - %message%newline / /layout /appender root appender-ref ref=WarningAppender / appender-ref ref=InfoAppender/ /root /log4net This way, if you log to the same logger, you'll get two separate messages in (potentially) two separate places. It sounds like you want to tackle a fairly common scenario: When your application encounters a fatal error, you want to receive a notification about it. You could set up your SNMP appender to have a threshold of FATAL. You would also receive that error in the other appenders you have set up. Typically, I would think you wouldn't care if you get the fatal error logged multiple times, especially so you could figure out (from the DEBUG log, for example) what your application was trying to do when the error occurred. Does that make sense? -Ross On Wed, Apr 8, 2009 at 10:33 AM, omatase omat...@gmail.com wrote: Daniel Marohn wrote: Hi! ... Someone else might have an application that they would like to send DEBUG messages to the FileAppender even though my application may only send FATAL ... this is, why you have different logger. from your first post: logger name=Invoicing ... /logger logger name=Invoicing ... /logger Yes, that *is* why I am doing that Daniel Marohn wrote: this makes no sense. You configure the logger 'Invoicing' and later you configure the SAME logger with different properties. How do you want to access these 'two' loggers from your code? LogManger.GetLogger(Invoicing, but please first version) ? ;-) log4net is intelligent enough to handle this. When you call : log4net.LogManager.GetLogger(loggerName).Debug(message, exception); or log4net.LogManager.GetLogger(loggerName).Error(message, exception); It will use the logger defined with value=DEBUG But, when you call log4net.LogManager.GetLogger(loggerName).Fatal(message, exception); log4net will use the logger defined with value=FATAL This allows me to use the same loggerName throughout my application, and have FATAL messages logged in a different manner. FATAL messages are more urgent and require immediate attention for this I will be using an SnmpAppender that will send the messages directly to our critical problem monitoring system. Daniel Marohn wrote: You can do this: appender name=consoleTestAppender type=log4net.Appender.ConsoleAppender layout type=log4net.Layout.PatternLayout conversionPattern value=%date %-5level %logger - %message%newline / /layout /appender logger name=Invoicing.Application1 level value=ERROR / appender-ref ref=consoleTestAppender / /logger logger name=Invoicing.Application2 level value=WARN / appender-ref ref=consoleTestAppender / /logger now you have two different loggers (one for each app), using the same appender. And you can set the Level per Logger. The invoicing application is a single application. If I were to define multiple loggers with different names I might do something like this instead: logger name=Invoicing.Logger1 level value=FATAL / appender-ref ref=consoleTestAppender / /logger logger name=Invoicing.Logger2 level value=WARN / appender-ref ref=consoleTestAppender / /logger The problem here is I am trying to send my critical errors to Snmp, so in my code I would have to remember the logger name I am using for critical errors (in this case Invoicing.Logger1). It is much simpler to just have to remember to call .Fatal when I have a critical error and not have to remember the loggername that was meant to handle fatal errors. -- View this message in context:
Re: Error destroying my productivity Please Help!: log4net:ERROR [] Attempted to append to closed appender named []
Does this work? logger name=Invoicing level value=DEBUG / appender-ref ref=AdoNetAppender / appender-ref ref=FileAppender / /logger - Original Message From: omatase omat...@gmail.com To: log4net-user@logging.apache.org Sent: Tuesday, April 7, 2009 6:17:29 PM Subject: Error destroying my productivity Please Help!: log4net:ERROR [] Attempted to append to closed appender named [] I cannot figure this one out. I have been tasked by my team to create a logging service so that we can all have convenient logging without having to integrate it into our individual projects. I decided to do this I would just build a wrapper around log4net that makes it even simpler to use than it already is. After not too much work I got it up and running and (seemingly) working. I had it running on a development web server here for people to begin using with no issues initially. Now I am getting this really really really crappy error whenever I try to write a log no matter the loglevel or the logger being used. I have narrowed it down to config file changes but cannot find an answer. The changes I narrowed it down to are: If I have the following configuration in my log4net xml section everything is fine root level value=DEBUG / appender-ref ref=AdoNetAppender / /root And if I add an additional logger suchas: logger name=Invoicing level value=DEBUG / appender-ref ref=AdoNetAppender / /logger we're still in good shape. But! When I add another logger with the same name as another existing logger suchas: logger name=Invoicing level value=FATAL / appender-ref ref=FileAppender / /logger all hell breaks loose and I get the following error: log4net:ERROR [] Attempted to append to closed appender named [] I am certain log4net is supposed to support a log strategy such as this so that I can have fatal messages logged differently for the same logger name. Can someone help me understand what's going on? I can post any and all code I have if it will help diagnose the problem. Thanks -- View this message in context: http://www.nabble.com/Error-destroying-my-productivity-Please-Help%21%3A-log4net%3AERRORAttempted-to-append-to-closed-appender-namedtp22939427p22939427.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: where is threadcontext
The link I posted is for the latest version of log4net: http://logging.apache.org/log4net/download.html - Original Message From: rodchar rodc...@hotmail.com To: log4net-user@logging.apache.org Sent: Monday, February 23, 2009 7:46:52 PM Subject: Re: where is threadcontext which version of log4net should we be using? we're using asp.net 2.0 fx Ron Grabowski wrote: http://logging.apache.org/log4net/release/manual/contexts.html using(log4net.ThreadContext.Stacks[NDC].Push(context)) { log.Info(Message); } - Original Message From: rodchar rodc...@hotmail.com To: log4net-user@logging.apache.org Sent: Monday, February 23, 2009 4:18:35 PM Subject: where is threadcontext hi all, i was looking at NDC in the log4net SDK and read the following: The NDC is deprecated and has been replaced by the Stacks. The current NDC implementation forwards to the ThreadContext.Stacks But i don't see it when i inspect the log4net namespace. i'm a noob to log4net please go easy. thanks, rodchar -- View this message in context: http://www.nabble.com/where-is-threadcontext-tp22170366p22170366.html Sent from the Log4net - Users mailing list archive at Nabble.com. -- View this message in context: http://www.nabble.com/where-is-threadcontext-tp22170366p22173638.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Change the log level programmatically?
// untested public class HierarchyLoggerLevelScope : IDisposable { private readonly Level originalLevel; private readonly Logger logger; public HierarchyLoggerLevelScope(ILog log, Level level) { logger = log.Logger as Logger; if (logger != null) { originalLevel = logger.Level; logger.Level = level; } } public void Dispose() { if (logger != null) { logger.Level = originalLevel; } } } - Original Message From: Eric Rose (erose) er...@cisco.com To: Log4NET User log4net-user@logging.apache.org Cc: Eric Rose (erose) er...@cisco.com Sent: Wednesday, February 11, 2009 10:11:12 AM Subject: RE: Change the log level programmatically? Thanks Nick, I'm not going to hack the log4net code, so that's not really an option. I'm asking about this, because one of the developers had asked if there was a way to do this. But, it sounds like it's not really possible, unless we want to modify the config file... So, thanks for the information! -esr -Original Message- From: Nick Durcholz [mailto:ndur...@e-farmcredit.com] Sent: Wednesday, February 11, 2009 10:01 AM To: Log4NET User Subject: RE: Change the log level programmatically? There isn't a clean way to do this with the interfaces provided. If you really MUST have this, you could probably hack something up, but it would require breaking some of the abstractions that the framework tries to enforce. You could also try loading the config xml into memory, modifying it using the dom, and then reconfiguring the entire heirarchy using log4net.Config.XmlConfigurator.Configure(ILoggerRepository repository, XmlElement element). I've never tried this, so can't really say what pitfalls and 'gotchas' come along with doing that. Why do you need to change the level of a logger at runtime in the first place? There may be a better way to accomplish the task at hand without doing that. From: Eric Rose (erose) [mailto:er...@cisco.com] Sent: Wednesday, February 11, 2009 9:37 AM To: Log4NET User Subject: RE: Change the log level programmatically? Hi, I sent this question a couple of weeks ago, but haven't heard any feedback from anyone... Could someone offer some suggestions here, or let me know that this can't be done?! Thanks, -esr From: Eric Rose (erose) Sent: Friday, January 30, 2009 10:22 PM To: log4net-user@logging.apache.org Subject: Change the log level programmatically? Hopefully this is an easy question which has already been asked (and answered) before. I searched online, but could not find a reasonable answer... Is there a way to change the default log level of a logger via C# program control? I don't need the setting to persist, so I don't want to have to change the XML config file and re-read it. In my C# code, I have a ILog variable that we use for all logging, defined as follows: private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMeth od().DeclaringType); I'd like to be able to somehow be able to use that 'log' variable, and set it's log level (INFO, WARN, ERROR, OFF, ALL, etc) to whatever I want in the code. Any help or pointers to useful examples would be appreciated! Thanks, -esr cid:image001.gif@01C7EFF5.57209E90 Eric Rose Software Engineer Product Development er...@cisco.com mailto:er...@cisco.com Phone :(978) 936-1858 Cisco Systems, Inc. 500 Beaver Brook Road Boxborough, MA 01719 www.cisco.com http://www.cisco.com
Re: Problems with Log4Net zip file
This is what my wget.exe looks like. I don't think we're in the Apache mirror system...the .zip file comes off just one server? Resolving archive.apache.org... 140.211.11.130 Connecting to archive.apache.org|140.211.11.130|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 8,203,576 (7.8M) [application/zip] 100%[] 8,203,576374.44K/sETA 00:00 17:26:21 (246.00 KB/s) - `incubating-log4net-1.2.10.zip' saved [8203576/8203576] From: Cristina cristina.alm...@gmail.com To: log4net-user@logging.apache.org Sent: Monday, February 9, 2009 10:40:37 AM Subject: Problems with Log4Net zip file Hi, I want to use the Log4Net in a new application I'm working, but I had some difficults to get the log4net bin to add on my application. I'm using .net framework 2.0. I already downloaded log4net 1.2.10 (zip) in this address: http://archive.apache.org/dist/incubator/log4net/1.2.10/incubating-log4net-1.2.10.zip When I click in incubating-log4net-1.2.10.zip I got an error saying the file can be corrupted or is invalid. I tryed the 1.2.9 version, and I got the same error. Only whith the 1.2.8 version, got at source forge page, i had no problems, but this version is not for the .net framework i using. Could you help me? thank you, Cristina Almada
Re: Using Log4Net for Distributed Logging
I'd start out using the remoting appender. If you want two processes to share the same log file you'll need to change the locking mechanism from the default ExclusiveLock to MinimalLock. Other alternatives include writing to real database server that can handle the concurrency. Someone posted a MutextLock to the list a while ago. I'm in the process of rewriting it to be included in the log4net distribution because the author didn't post any comments on where the code from or if it was ok to ship with log4net. - Original Message From: Deep George dee...@hotmail.com To: log4net-user@logging.apache.org Sent: Tuesday, February 3, 2009 1:10:05 AM Subject: Using Log4Net for Distributed Logging Hi, I am relatively new to Log4Net. I would like to know whether Log4Net can be used for logging in a distributed environment. I am looking at 2 scenarios- Scenario 1: A 20 server site. One of the server takes care of logging (Logging Server). Every other servers pushes the log information to this centralized logging server. Which appender can i use ? (RemoteAppender?) Scenario 2: Here, there are 2 processes (Process A, Process B) running on the same host, using log4Net for logging. Is it possible for both the processes to share the log? Let say, both the processes use LogFileAppender, will they be able to share the same log file? Also, please suggest a good link/book about distributed logging using Log4Net. Thanks. -- View this message in context: http://www.nabble.com/Using-Log4Net-for-Distributed-Logging-tp21804464p21804464.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: ADO.Net appender configuration for sybase?
What Sybase type implements IConnection? From: Ranjan, Bibhakar bibhakar_ran...@intuit.com To: log4net-user@logging.apache.org Sent: Wednesday, January 28, 2009 6:21:32 AM Subject: ADO.Net appender configuration for sybase? In log4net configuration, we have found sample xml code for most of the common RDBMS except Sybase. Could you please tell me how can I configure the Sybase database with log4net using ADONet appender? Thanks Bibhakar
CodeMash 2009
Are any log4net'ers going to CodeMash in early January in Sandusky, OH? I'll be there if anyone wants to nag me about a log4net release in person :-) - Ron
Re: CustomAppender and property
Log4net uses reflection to look see if the xml node name matches a public property on your object. From: Pascal ROZE pascal.r...@gmail.com To: log4net-user@logging.apache.org Sent: Tuesday, December 16, 2008 4:44:42 AM Subject: CustomAppender and property Hi all I'm developping my own appender. Looking at some examples in the Net, I've found how to create property, I just have to use the same name in appender file and config file. - In the config file: myProperty value=HelloWorld / - In the appender file: private string m_myproperty public string MyProperty { get { returm m_myproperty; } set { m_mypropery = value; } } I was wondering how it works but I didn't find the class/function in log4net sources. Can anyone help me? Thx a lot Cheers Pascal
Re: CustomAppender and property
log4net.Repository.Hierarchy.XmlHierarchyConfigurator.SetParameter From: Pascal ROZE pascal.r...@gmail.com To: Log4NET User log4net-user@logging.apache.org Sent: Tuesday, December 16, 2008 9:13:38 AM Subject: Re: CustomAppender and property Do you know in what class/function this job is done in log4net sources? 2008/12/16 Ron Grabowski rongrabow...@yahoo.com Log4net uses reflection to look see if the xml node name matches a public property on your object. From: Pascal ROZE pascal.r...@gmail.com To: log4net-user@logging.apache.org Sent: Tuesday, December 16, 2008 4:44:42 AM Subject: CustomAppender and property Hi all I'm developping my own appender. Looking at some examples in the Net, I've found how to create property, I just have to use the same name in appender file and config file. - In the config file: myProperty value=HelloWorld / - In the appender file: private string m_myproperty public string MyProperty { get { returm m_myproperty; } set { m_mypropery = value; } } I was wondering how it works but I didn't find the class/function in log4net sources. Can anyone help me? Thx a lot Cheers Pascal
Re: Best Way to Set Up Massive Number of Loggers
If you don't want to type the same pattern over and over, extend PatternLayout and provide your own default pattern: layout type=Company.Logging.MyPatternLayout, Company.Logging / That can be overridden when necessary: layout type=Company.Logging.MyPatternLayout, Company.Logging conversionPattern value=%d %m%n / /layout You can also extend RollingFileAppender and set default values in there: appender name=Comp1 type=Company.Logging.CompRollingFileAppender, Company.Logging comp value=1/ /appender appender name=Comp2 type=Company.Logging.CompRollingFileAppender, Company.Logging comp value=2/ /appender appender name=Comp3 type=Company.Logging.CompRollingFileAppender, Company.Logging comp value=3/ layout type=Company.Logging.MyPatternLayout, Company.Logging conversionPattern value=%d %m%n / /layout /appender appender name=Comp4 type=Company.Logging.CompRollingFileAppender, Company.Logging comp value=4/ /appender - Original Message From: Loren Keagle lo...@aps-technology.com To: Log4NET User log4net-user@logging.apache.org Sent: Tuesday, December 2, 2008 2:19:47 AM Subject: Re: Best Way to Set Up Massive Number of Loggers This is the only way I know how to do this in log4net. We do this to handle remote logging from embedded controllers. We use .NET remoting appenders in this case, so we get the HostName property of each remote host logging to the sink. But if you're local you could do the same thing with a string filter or other property filter. This gives you individual layout control over each appender, and hence each log source. If only log4net would add in a layout-ref tag so we wouldn't have to repeat ourselves 75 times... log4net appender name=ConsoleAppender type=log4net.Appender.ConsoleAppender layout type=log4net.Layout.PatternLayout param name=ConversionPattern value=%property{log4net:HostName} %d{MM/dd/ HH:mm:ss.fff} [%p] %c{1}: %m%n / /layout /appender appender name=Comp1 type=log4net.Appender.RollingFileAppender file value=Comp1/Comp1.log / staticLogFileName value=true / filter type=log4net.Filter.PropertyFilter Key value=log4net:HostName / StringToMatch value=Comp1 / /filter filter type=log4net.Filter.DenyAllFilter / appendToFile value=true / rollingStyle value=Date / datePattern value=MMdd’.log’ / layout type=log4net.Layout.PatternLayout param name=ConversionPattern value=%d{MM/dd/ HH:mm:ss.fff} [%p] %c{1}: %m%n / /layout /appender appender name=Comp2 type=log4net.Appender.RollingFileAppender file value=Comp2/Comp2.log / staticLogFileName value=true / filter type=log4net.Filter.PropertyFilter Key value=log4net:HostName / StringToMatch value=Comp2 / /filter filter type=log4net.Filter.DenyAllFilter / appendToFile value=true / rollingStyle value=Date / datePattern value=MMdd / layout type=log4net.Layout.PatternLayout param name=ConversionPattern value=%d{MM/dd/ HH:mm:ss.fff} [%p] %c{1}: %m%n / /layout /appender appender name=Comp3 type=log4net.Appender.RollingFileAppender file value=Comp3/Comp3.log / staticLogFileName value=true / filter type=log4net.Filter.PropertyFilter Key value=log4net:HostName / StringToMatch value=Comp3 / /filter filter type=log4net.Filter.DenyAllFilter / appendToFile value=true / rollingStyle value=Date / datePattern value=MMdd / layout type=log4net.Layout.PatternLayout param name=ConversionPattern value=%d{MM/dd/ HH:mm:ss.fff} [%p] %c{1}: %m%n / /layout /appender ... root level value=ALL / appender-ref ref=ConsoleAppender / appender-ref ref=Comp1 / appender-ref ref=Comp2 / appender-ref ref=Comp3 / ... /root /log4net Eric Marthinsen wrote: Hi Walden- I like the grep idea. The motivation for the multiple log files is twofold. First, they get really big really quickly. I realize I can roll them on size, but it's nice to have a daily log file. Second, we have some utilities that can take a log file and replay previous transactions (we are logging a lot of data in custom formats). These are still programmer tools (and QA). -Eric On Mon, Dec 1, 2008 at 7:39 PM, Walden H. Leverich wald...@techsoftinc.com mailto:wald...@techsoftinc.com wrote: Since you're asking for thoughts... bad idea. To me log4net is plumbing, that is it's programmer based stuff. Sounds to me like you're attempting to use it to satisfy a user requirement. I think you'd be better off adding the logging as part of the business processing. Now, having said that, there are still times when it's nice to know which trading partner you're dealing with on a log message. In that case I'd push the partner id into the NDC at the start of the process, and pop it at the end. That way you'll have it in the log (if you format it correctly). You'll have a single log file, but you can always fgrep it. We do something similar with several levels of NDC and can quickly come up with a issue-specific logfile using grep. -Walden --
Re: Best Way to Set Up Massive Number of Loggers
It would be nice if the File property on the FileAppender had more robust support for patterns so you could write to a dynamic file. NLog and log4j have had support for this for a while. I think they keep a pool of files open then close a file if it hasn't been used recently. From: Eric Marthinsen emarthin...@agilecommerce.com To: Log4NET User log4net-user@logging.apache.org Sent: Monday, December 1, 2008 7:48:46 PM Subject: Re: Best Way to Set Up Massive Number of Loggers Hi Walden- I like the grep idea. The motivation for the multiple log files is twofold. First, they get really big really quickly. I realize I can roll them on size, but it's nice to have a daily log file. Second, we have some utilities that can take a log file and replay previous transactions (we are logging a lot of data in custom formats). These are still programmer tools (and QA). -Eric On Mon, Dec 1, 2008 at 7:39 PM, Walden H. Leverich wald...@techsoftinc.com wrote: Since you're asking for thoughts... bad idea. To me log4net is plumbing, that is it's programmer based stuff. Sounds to me like you're attempting to use it to satisfy a user requirement. I think you'd be better off adding the logging as part of the business processing. Now, having said that, there are still times when it's nice to know which trading partner you're dealing with on a log message. In that case I'd push the partner id into the NDC at the start of the process, and pop it at the end. That way you'll have it in the log (if you format it correctly). You'll have a single log file, but you can always fgrep it. We do something similar with several levels of NDC and can quickly come up with a issue-specific logfile using grep. -Walden -- Walden H Leverich III Tech Software (516) 627-3800 x3051 wald...@techsoftinc.com http://www.TechSoftInc.com Quiquid latine dictum sit altum viditur. (Whatever is said in Latin seems profound.) From:Eric Marthinsen [mailto:emarthin...@agilecommerce.com] Sent: Monday, December 01, 2008 7:31 PM To: log4net-user@logging.apache.org Subject: Best Way to Set Up Massive Number of Loggers Hello- I'm working on an app that coordinates data transfers among multiple trading partners. I want to create a log file for each trading partner. I had a few ideas of how to do this, but am not sure which would be considered the optimal way. The expected number of trading partners is likely to be around 100, but could be higher. Here are my thoughts: 1. Add a bunch of named loggers to my log4net.config file 2. Do programmatic configuration of the loggers on application start 3. Write my own appender that is based on the RollingFileAppender Do any of these scream out as being a good or bad solution? Is there a better approach that I might be missing? Thanks in advance. Regards, Eric
Re: configuration problems, not logging
What happens when you make the buffer size 1? - Original Message From: suedeuno [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Tuesday, November 25, 2008 3:05:29 PM Subject: configuration problems, not logging What's missing here? Using profiler, the database never receives the call. web.config: log4net appender name=ADONetAppender type=log4net.Appender.ADONetAppender bufferSize value=100 / [snip]
Re: configuration problems, not logging
I don't know if it matters or not but the Type is AdoNetAppender not ADONetAppender. Do you see a TypeLoadException when you turn on log4net's internal debugging? - Original Message From: suedeuno [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Tuesday, November 25, 2008 3:05:29 PM Subject: configuration problems, not logging What's missing here? Using profiler, the database never receives the call. web.config: log4net appender name=ADONetAppender type=log4net.Appender.ADONetAppender bufferSize value=100 / connectionType value=System.Data.SqlClient.SqlConnection, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 / connectionString value=data source=(local)\SQLEXPRESS;initial catalog=MyTestDB;integrated security=false;persist security info=True;User ID=user;Password=pass / commandText value=INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message],[Exception]) VALUES (@log_date, @thread, @log_level, @logger, @message, @exception) / etc root level value=ERROR / appender-ref ref=ADONetAppender / /root logger name=LogUtility level value=ALL / /logger /log4net global.asax application_start log4net.Config.XmlConfigurator.Configure(); log wrapper: public class LogUtility : ILogUtility { private ILog log { get; set; } public LogUtility() { log = LogManager.GetLogger(LogUtility); // LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); } #region ILogUtility Members public void LogException(string message) { log.Error(message); } public void LogException(string message, Exception exception) { log.Error(message, exception); } default.aspx log call: LogUtility.LogException(some error, new Exception()); -- View this message in context: http://www.nabble.com/configuration-problems%2C-not-logging-tp20688643p20688643.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: AdoNetAppender connection timeouts
The AdoNetAppender keeps a reference to an open connection. At some point it ensures the connection is open: // shortened somewhat...the actual code is longer if (m_reconnectOnError m_dbConnection.State != ConnectionState.Open) { LogLog.Debug(Attempting to reconnect to database...); InitializeDatabaseConnection(); InitializeDatabaseCommand(); } The AdoNetAppender is not async by default. If you're on SqlServer I'd recommend taking a look at an appender that Ayende wrote: https://rhino-tools.svn.sourceforge.net/svnroot/rhino-tools/trunk/rhino-commons/Rhino.Commons/Logging/AsyncBulkInsertAppender.cs whichs usess the SqlBulkCopy (very fast!) and background threads to write log messages to the database. From: Hadley Willan [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Friday, November 14, 2008 1:56:40 AM Subject: AdoNetAppender connection timeouts Hi peoples, How does the ADO.Net appender handle intermittent connections? I’m assuming that it’s holding a connection open and appending? I have bufferSize value=”0” set to ensure an immediate call to a stored proc for logging. So basically, do I need to worry about whether or not my connection to the other end exists? Could the lack of a network connection translate to a pause in the app when the log statement gets written? Or is all logging an asynchronous thread that doesn’t affect the caller? Thanks in advance. Hadley Bunnings Legal Disclaimer: 1) This email is confidential and may contain legally privileged information. If you are not the intended recipient, you must not disclose or use the information contained in it. If you have received this email in error, please notify us immediately by return email and delete the document. 2) All emails sent to and sent from Bunnings Group Limited. are scanned for content. Any material deemed to contain inappropriate subject matter will be reported to the email administrator of all parties concerned.
Re: SQL 2005 Database Mirroring Support
The system.diagnostics node needs to go in App.Config. log4net produces quite a bit of internal debug messages even if there isn't a problem so you should at least be seeing that. From: Gourlay, Colin [EMAIL PROTECTED] To: Log4NET User log4net-user@logging.apache.org Sent: Wednesday, November 12, 2008 7:05:01 AM Subject: RE: SQL 2005 Database Mirroring Support Hello. When I turn on internal debugging I get nothing at all. This is a web application (using Windows authentication) and the user has write permissions to the folder I created where I wanted the log4net debugging output be rendered to. In case this is significant I added the following to the web.config file: add key=log4net.Internal.Debug value=true/ And added the following to the logging.config file (the logging information is held in a separate config file). I use ConfigureAndWatch() to pick up the changes but just to be sure that it picked up the additions I restarted the web site in IIS. system.diagnostics trace autoflush=true listeners add name=textWriterTraceListener type=System.Diagnostics.TextWriterTraceListener initializeData=C:\tmp\log4net.txt / /listeners /trace /system.diagnostics Any thoughts? Colin From:Ron Grabowski [mailto:[EMAIL PROTECTED] Sent: 11 November 2008 22:12 To: Log4NET User Subject: Re: SQL 2005 Database Mirroring Support Importance: Low What does log4net report as the error when you turn on internal debugging? From:Gourlay, Colin [EMAIL PROTECTED] To: Log4NET User log4net-user@logging.apache.org Sent: Tuesday, November 11, 2008 11:07:33 AM Subject: RE: SQL 2005 Database Mirroring Support Hi Dag. Thanks for your response. Unfortunately I am still no further forward on this despite following your suggestion. I have included further information if this helps. Suggestions/Advice are very much appreciated. Both servers are fully service packed and are running with Log4Net v1.2.10 SQL 2005 .Net 3.5 My log4net configuration is as follows: log4net root level value=DEBUG / appender-ref ref=LogToSqlServer/ /root appender name=LogToSqlServer type=log4net.Appender.AdoNetAppender filter type=log4net.Filter.LoggerMatchFilter loggerToMatch value=NHibernate / acceptOnMatch value=false / /filter bufferSize value=0/ !--threshold value=DEBUG/-- connectionType value=System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089/ connectionString value=data source=SERVER-NAME-IS-HERE;initial catalog=LOGGING-DATABASE-IS-HERE;integrated security=true;/ commandText value=EXEC STORED-PROC-NAME-IS-HERE @User, @Logger, @LoggingLevel, @Message/ parameter parameterName value=@User/ dbType value=String/ size value=255/ layout type=log4net.Layout.PatternLayout conversionPattern value=%identity/ /layout /parameter parameter parameterName value=@Logger/ dbType value=String/ size value=255/ layout type=log4net.Layout.PatternLayout value=%logger/ /parameter parameter parameterName value=@LoggingLevel/ dbType value=String/
Re: Trying to set up an EXTREMELY SIMPLE event log feature... and failing terribly! Please help a newbie
The first thing I would is to make sure log4net itself is working. Your config file runs correctly when I add a ConsoleAppender: ?xml version=1.0 encoding=utf-8 ? configuration configSections section name=log4net type=log4net.Config.Log4NetConfigurationSectionHandler, log4net / /configSections log4net appender name=EventLogAppender type=log4net.Appender.EventLogAppender layout type=log4net.Layout.SimpleLayout / /appender appender name=ConsoleAppender type=log4net.Appender.ConsoleAppender layout type=log4net.Layout.SimpleLayout / /appender root level value=ALL / appender-ref ref=EventLogAppender / appender-ref ref=ConsoleAppender / /root /log4net /configuration I can also see the entries in the Event Log. Internal debugging: appSettings add key=log4net.Internal.Debug value=true / /appSettings didn't show any problems. Do you get an exceptions when internal debugging is turned on? From what I can tell it looks like there's something wrong with the machine its running on. - Original Message From: talktopete [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Tuesday, November 11, 2008 4:34:20 PM Subject: Trying to set up an EXTREMELY SIMPLE event log feature... and failing terribly! Please help a newbie Hi and thanks in advance for the help. I'm tearing my hair out over here trying to get this to work: a siple logger that writes to the application section of the event log. This is using log4net 1.2.10.0 Here is the app config: -- ?xml version=1.0 encoding=utf-8 ? configuration configSections section name=log4net type=log4net.Config.Log4NetConfigurationSectionHandler, log4net / /configSections log4net appender name=EventLogAppender type=log4net.Appender.EventLogAppender layout type=log4net.Layout.PatternLayout conversionPattern value=%date [%thread] %-5level %logger [%property{NDC}] - %message%newline / /layout /appender root level value=ALL / appender-ref ref=EventLogAppender / /root /log4net /configuration here is my code: log4net.Config.XmlConfigurator.Configure(); logger = LogManager.GetLogger(EventLogAppender); logger.Error(test); --- No errors, nothing happens! I notice that there are no appenders. nothing is written to the event log. I am tearing my hair out trying to figure out what is going on, can somebody help? -- View this message in context: http://www.nabble.com/Trying-to-set-up-an--EXTREMELY-SIMPLE-event-log-feature...-and-failing-terribly%21-Please-help-a-newbie-tp20448428p20448428.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Help me with dinamically setting up the RollingFileAppender please
You probably need to call appender.ActivateOptions() before calling Configure(). From: Pavel Bazanov [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Monday, October 27, 2008 6:16:56 AM Subject: Help me with dinamically setting up the RollingFileAppender please Hello, I have just downloaded the log4net and I can't use the RollingFileAppender. Check my code please: // ### var appender = new log4net.Appender.RollingFileAppender(); appender.AppendToFile = true; appender.File = log.txt; appender.MaxFileSize = 1; appender.MaxSizeRollBackups = 10; appender.RollingStyle = log4net.Appender.RollingFileAppender.RollingMode.Size; log4net.Config.BasicConfigurator.Configure(appender); log.Info(event occurred); // ### No errors produced, but no log file is created, it just looks like nothing happens. What am I doing wrong? Thank you in advance.
Re: Using log4Net to log multiple files by different users/tasks
In your code the File property gets set when the Appender is created. Here's an example showing how to set the File property based on each logging event: http://svn.apache.org/viewvc/logging/log4net/trunk/examples/net/1.0/Appenders/SampleAppendersApp/cs/src/Appender/PatternFileAppender.cs?view=markup That example code is probably slow. log4j and nlog have file appenders that keep the most recent files open so you don't have to pay the open/close penalty. You could probably extend the FileAppender and override a method or two to do what you want. - Original Message From: Mark A. DeMichele [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Sunday, October 5, 2008 9:43:05 AM Subject: Using log4Net to log multiple files by different users/tasks I have an asp.net site in which different users run different tasks. Each individual task is managed by a TaskManager that I'm writing. While each task is running it has the opportunity to log to it's own log file. I'm trying to use Log4Net to do this, but so far I've been unable to figure out how exactly to accomplish this. Any advice would be appreciated. So far, I believe I must create an individual Appender for each task. Something like this. PatternLayoutlayout = newPatternLayout(%date{dd-MM- HH:mm:ss,fff} %5level [%2thread] %message (%logger{1}:%line)%n); FileAppenderappender = newFileAppender(); appender.Layout = layout; appender.File = d:\\logs\\+ TaskID.ToString()+ .txt; appender.AppendToFile = true; appender.Name = File; appender.Threshold = log4net.Core.Level.All; appender.ActivateOptions(); And I know that eventaully, I'll want to code to call something like ILog _Log = LogManager.GetLogger(TaskID.ToString()); But I can't figure out how to make that logger unique and how to associate that single appender to it and not to have that single appender interfere with other users and tasks. I'm starting to think that this is not possible with Log4Net. Maybe Log4Net is made more to have global loggers and not many individual task related ones. I'd appreciate any help anyone can give me. Thanks.
Re: Using log4Net to log multiple files by different users/tasks
The source code to log4net is available at: http://svn.apache.org/viewvc/logging/log4net/trunk/src/ If you're wondering how something works that may be a better place to look. Most (all?) of the source is commented. Its acceptable to create a new repository for medium to long running tasks. When you shutdown the repository it automatically shuts down all of its appenders and loggers. - Original Message From: Mark A. DeMichele [EMAIL PROTECTED] To: Log4NET User log4net-user@logging.apache.org Sent: Sunday, October 5, 2008 6:19:07 PM Subject: RE: Using log4Net to log multiple files by different users/tasks I'm not sure you're completing understanding my dilema. I need to basically create loggers on the fly which are associated with separate files. I did actually get something working, but now I can't figure out how to clean up. This is what I have so far. To start I create a repostitory and give it a name. I then store the repository pointer in a static variable. Then when I start a specific task, I use the repository to create a logger and I add a file appender to that logger. The file appender is associtated with a unique file name. My task has a unique id and I used tha same id to name the logger. All my logging for that task uses that logger with that name and everything seems ok. Now here's the problem. When my task is done, I would like to clean up that logger and remove it from the repositry, but there doesn't seem to be a way to do this. I fear that based on my design, if my server is running for days on end, the hash table where the loggers are stored in the repository will grow and grow. I used Reflector to look at the code in the Hierarchy object. but there doesn't seem to be a way to remove an object from the hash table. From: Ron Grabowski [mailto:[EMAIL PROTECTED] Sent: Sunday, October 05, 2008 11:51 AM To: Log4NET User Subject: Re: Using log4Net to log multiple files by different users/tasks In your code the File property gets set when the Appender is created. Here's an example showing how to set the File property based on each logging event: http://svn.apache.org/viewvc/logging/log4net/trunk/examples/net/1.0/Appenders/SampleAppendersApp/cs/src/Appender/PatternFileAppender.cs?view=markup That example code is probably slow. log4j and nlog have file appenders that keep the most recent files open so you don't have to pay the open/close penalty. You could probably extend the FileAppender and override a method or two to do what you want. - Original Message From: Mark A. DeMichele [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Sunday, October 5, 2008 9:43:05 AM Subject: Using log4Net to log multiple files by different users/tasks I have an asp.net site in which different users run different tasks. Each individual task is managed by a TaskManager that I'm writing. While each task is running it has the opportunity to log to it's own log file. I'm trying to use Log4Net to do this, but so far I've been unable to figure out how exactly to accomplish this. Any advice would be appreciated. So far, I believe I must create an individual Appender for each task. Something like this. PatternLayoutlayout = newPatternLayout(%date{dd-MM- HH:mm:ss,fff} %5level [%2thread] %message (%logger{1}:%line)%n); FileAppenderappender = newFileAppender(); appender.Layout = layout; appender.File = d:\\logs\\+ TaskID.ToString()+ .txt; appender.AppendToFile = true; appender.Name = File; appender.Threshold = log4net.Core.Level.All; appender.ActivateOptions(); And I know that eventaully, I'll want to code to call something like ILog _Log = LogManager.GetLogger(TaskID.ToString()); But I can't figure out how to make that logger unique and how to associate that single appender to it and not to have that single appender interfere with other users and tasks. I'm starting to think that this is not possible with Log4Net. Maybe Log4Net is made more to have global loggers and not many individual task related ones. I'd appreciate any help anyone can give me. Thanks.
Re: Replacing text in log messages
IObjectRender was designed to allow custom objects (i.e. non-value objects) to be formatted. log4net optmizes string messages by bypassing the IObjectRenderer code. I don't think a lot of people use IObjectRender. If you want to use an object renderer you can wrap your sensitive messages like this: SensitiveString sensitiveString = new SensitiveString(My password is 1234); log.Info(sensitiveString); then register the renderer for the SensitiveString class. I'd probably write a ForwardingAppender or a Filter that alters the message before the real Appender receives the message. - Original Message From: Lars Bjønnes [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Thursday, October 2, 2008 2:44:52 PM Subject: Replacing text in log messages Hello, I am trying to replace certain text strings in log messages, based on a regular expression. The goal is to prevent sensitive information being logged. Is there any easy way of doing this? I have so far tried to write a simple implementation of the IObjectRenderer as a small end to end test namespace Log4netRegexpRenderer { public class RegexpObjectRenderer : IObjectRenderer { /// summary /// Proceed to rendering for a given object. /// /summary public string DoRender(RendererMap rendererMap, object obj) { return Yeah, we're getting somehwere; } } } Then adding this to log4net.config: renderer renderingClass=Log4netRegexpRenderer.RegexpObjectRenderer, Log4netRegexpRenderer renderedClass=System.String, mscorlib / When I set the internal debug property in log4net to true, I can see that my assembly is pickedup and that there indeed is initialized an instance of my RegexpObjectRenderer. However, it never calls DoRender in my custom object renderer. Is it possible to catch System.String/string by (mis)using the ObjectRenderer, or do I have to use custom objects? (Which works fine) (I have no problems getting a custom renderer to work with my own custom classes, but no luck with System.String). Suggestions? Regards, Lars
Re: Chained loggers
When the xml config file is being parsed the nodes in the config file are matched to properties on the appender. When multiple properties need to be set log4net looks for a method beginning with the word Add. Most (all?) the appenders in log4net extend AppenderSkeleton. AppenderSkeleton has an AddFilter method which is how multiple filters can be added to an appender via the config file: appender name=FileAppender type=log4net.Appender.FileAppender file value=log.txt / !-- AppenderSkeleton.AddFilter is called for each filter node -- filter filter type=Company.Logging.CustomFilter1 / filter type=Company.Logging.CustomFilter2 / filter type=log4net.Filter.DenyAllFilter / /filter /appender This blog post might be helpful to you: http://weblogs.asp.net/tgraham/archive/2007/03/15/a-realistic-log4net-config.aspx - Original Message From: Daniel Bigham [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Wednesday, October 1, 2008 5:27:03 PM Subject: Chained loggers Hi, I'm trying to create a chained logger according to the following logic: if ( condition1 == true condition2 == true ) { accept } How can this be specified in XML? Here is what I have tried: appender name=SupportToolAppender type=log4net.Appender.AdoNetAppender filter type=log4net.Filter.PropertyFilter acceptOnMatch value=false / key value=eventid / regexToMatch value=\d+ / next type=log4net.Filter.LevelRangeFilter acceptOnMatch value=true / levelMin value=INFO / levelMax value=FATAL / /next /filter filter type=log4net.Filter.DenyAllFilter / ... /appender I guess more specifically my question is how the next property can be used to define the next logger in the chain. The above doesn't seem to work. I've tried some other things such as: next filter ... ... /filter /next ... but that doesn't work either. I don't see any documentation on the log4net site that explains how this is to be done, and Googling it hasn't helped much either. Thanks, Daniel -- Daniel Bigham Software Developer Navtech, Inc. 295 Hagey Blvd., Suite 200 Waterloo, Ontario, N2L 6R5 tel: (519) 747 1170 x.301 fax: (519) 747-1003 [EMAIL PROTECTED] -- Daniel Bigham Software Developer Navtech, Inc. 295 Hagey Blvd., Suite 200 Waterloo, Ontario, N2L 6R5 tel: (519) 747 1170 x.301 fax: (519) 747-1003 [EMAIL PROTECTED]
Re: logger and app domains
My first thought would be to use .NET Remoting with named pipes. Did you try that? - Original Message From: Peter Drier [EMAIL PROTECTED] To: Log4NET User log4net-user@logging.apache.org Sent: Saturday, September 20, 2008 1:57:11 PM Subject: Re: logger and app domains We're using log4net in an multi app domain application.. Lets say it was tricky.. Not sure if this would solve your problem, but this is what we did: 1. In the root app domain, we setup log4net as normal.. And added a custom Plugin that we wrote to the l4n interface that was accessible to our child domains. 1.. In each child app domain, we setup l4n with a single custom appender that knew how to find the plugin from #1 and forward all events to it, after a few checks to ensure that exceptions were serializable. So now anything logged in the child domain was sent to the parent, to follow the config rules and get logged out as necessary. Cheers, Peter -- Peter's Photography www.PeterDrier.com 2008/9/18 Graham Walsh [EMAIL PROTECTED] Hi, I have an issue with a GUI app I'm running. I make calls across dll's as expected and my logging works fine. I have a richTextappender in place thats used by the GUI. As logging is done I see it in the richText box of my gui. We'll call this normal execution. Now as part of our testing, I create an appDomain and make the method calls just as does the normal execution. I want this new appdomain to log to the same richTextBox however its not. In an attempt to take another approach, I tried to get the ILog object from the Normal execution and set it in the newly created AppDomain. This cant be done as; - System.Runtime.Serialization.SerializationException:Type 'log4net.Core.LogImpl' in Assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' is not marked as serializable. So I'm stuck. Anybody know how I can work around this issue? thanks much Graham Ce message et ses pièces jointes (le message) est destiné à l'usage exclusif de son destinataire. Si vous recevez ce message par erreur, merci d'en aviser immédiatement l'expéditeur et de le détruire ensuite. Le présent message pouvant être altéré à notre insu, CALYON Crédit Agricole CIB ne peut pas être engagé par son contenu. Tous droits réservés. This message and/or any attachments (the message) is intended for the sole use of its addressee. If you are not the addressee, please immediately notify the sender and then destroy the message. As this message and/or any attachments may have been altered without our knowledge, its content is not legally binding on CALYON Crédit Agricole CIB. All rights reserved.
Re: Whatever happened to asp.net pattern converters?
I'm still working on them. What functionality are you looking at using? - Original Message From: Jon Sheldon [EMAIL PROTECTED] To: log4net-user@logging.apache.org log4net-user@logging.apache.org Sent: Thursday, August 28, 2008 4:07:28 PM Subject: Whatever happened to asp.net pattern converters? Hello, I’m very interested in using log4net as my companies standard logging utility. Since our focus is primarily on developing web applications using asp.net, I’m very interested in the AspNet*PatternConverter classes that Ron started to implement back in October 2006. Is there a new release of log4net that is coming out soon that will include them? Or should I create my own layout class that implements ILayout and similar asp.net httpcontext focused PatternConverter classes? Thanks. Jon jon scott-sheldon senior internet applications architect mcp [EMAIL PROTECTED] 860.679.9332 x 318 acsysinteractive.com acsysinteractive connecticut | new york
Re: Multiple Layouts to the same appender
You shouldn't be using a layout on the ForwardingAppender. The ForwardingAppender always ignores that value. log4net doesn't concatenate the layout from your ForwardingAppender with the Console/RollingFileAppender. You'll have to copy the %m to the Console/RollingFileAppenders' layout. - Original Message From: Loren Keagle [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Friday, August 22, 2008 8:01:57 PM Subject: Multiple Layouts to the same appender I have an application that contains a subsystem with its own logging infrastructure. I can hook into this logging system to intercept the log messages, but the messages are already formatted. Rather than parse and decompose these messages, I simply used a PatternLayout to match the layout of the subsystem. However, I also need to log from my own code to the same file. This means I need to have an empty layout for the logger that's logging the subsystem messages, and a formatted layout for all the other loggers. I've tried using a ForwardingAppender, and setting a layout in there, but that layout is overridden by the layout in the FileAppender. If I leave the layout off of ForwardingAppender, I get a log4net error. It seems as though the chain of responsibility is reversed for the layouts than what it should be... Shouldn't log4net use the first layout it finds as it traces up the hierarchy, rather than the root layout? Why is the layout in my ForwardingAppender ignored? Here is my config block: log4net appender name=ConsoleAppender type=log4net.Appender.ConsoleAppender layout type=log4net.Layout.PatternLayout ConversionPattern value= %d{HH:mm:ss.fff} %14c{1} %m%n / /layout /appender appender name=RollingFileAppender type=log4net.Appender.RollingFileAppender file value=log.txt / appendToFile value=true / rollingStyle value=Size / maxSizeRollBackups value=5 / maximumFileSize value=10MB / staticLogFileName value=true / layout type=log4net.Layout.PatternLayout ConversionPattern value= %d{HH:mm:ss.fff} %14c{1} %m%n / /layout /appender appender name=ForwardingAppender type=log4net.Appender.ForwardingAppender appender-ref ref=ConsoleAppender / appender-ref ref=RollingFileAppender / layout type=log4net.Layout.PatternLayout ConversionPattern value=%m / /layout /appender root level value=DEBUG / appender-ref ref=RollingFileAppender / appender-ref ref=ConsoleAppender / /root logger name=subsystem additivity=false appender-ref ref=ForwardingAppender / /logger /log4net
Re: Conigure log4net for .net dll
Have you verified that your App.Config configures log4net correctly? What happens when you turn on log4net's internal debugging? - Original Message From: Debashish [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Wednesday, August 13, 2008 3:43:22 PM Subject: Conigure log4net for .net dll Hi I am developing a ClassLibrary in C#(VS2008). I have refernce to log4net.dll. This DLL has only one function which will log a string using log4net. My AssemblyInfo.cs has the following entry: [assembly: log4net.Config.XmlConfigurator()] I use this above dll in a WINForms application. The problem is log4net is not logging any information. Appreciate help. -- View this message in context: http://www.nabble.com/Conigure-log4net-for-.net-dll-tp18969861p18969861.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: ASP.NET, AdoNetAppender and deferred property execution
Have you tried setting the Fix property to All or Partial? http://logging.apache.org/log4net/release/sdk/log4net.Appender.BufferingAppenderSkeleton.Fix.html - Original Message From: Jerry Shea [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Monday, August 11, 2008 12:30:43 AM Subject: Re: ASP.NET, AdoNetAppender and deferred property execution Hi Everyone, Apologies for sending multiple messages about this, but I guess my initial question was buried at the bottom of email#1. Does anyone have a idea as to how I can force properties to be resolved at log time rather than flush time? Thx, Jerry 2008/8/7 Jerry Shea [EMAIL PROTECTED] Yes I have confirmed that this is the case - when the AdoNetAppender's buffer flushes then and only then are the properties evaluated.
Re: Adding properties to a logging event
It should be the Type of the current class that's doing the logging: private readonly static Type declaringType = typeof(ExtendedLogger); This is an ok way to add additional properties to a loggingEvent: loggingEvent.Properties[Additional] = Additional info; - Original Message From: Michael Richman [EMAIL PROTECTED] To: log4net-user@logging.apache.org log4net-user@logging.apache.org Sent: Wednesday, August 6, 2008 3:03:51 PM Subject: Adding properties to a logging event I'm trying to add properties to a logging event so that the adoAppender can=pick up these properties and use them in the insert SQL statement. I've followed the example of creating a loggingEvent, but for the life of me, I can't figure out what the callStackBoundaryDeclaringType would be. Can someone help me figure out what the first parameter is to pass to the LoggingEvent constructor? Also, is there a simpler way to add event specific context so that the appender can pick up the properties? I know I can use MDC or NDC or thread context or global context, but these are properties that are specific to the event, not those larger contexts. My code fragment is as follows: log4net.Core.LoggingEvent loggingEvent =3D new log4net.Core.LoggingEvent(ca= llerStackBoundaryDeclaringType, log.Logger.Repository, log.Logger.Name, log4net.Core.Level.Info, This is a Message, new Exception()); loggingEvent.Properties[Additional] =3D Additional info; log.Logger.Log(loggingEvent);
Re: log text wrap
You can use this example layout code: http://svn.apache.org/viewvc/logging/log4net/trunk/examples/net/1.0/Layouts/SampleLayoutsApp/cs/src/Layout/LineWrappingLayout.cs?view=markup - Original Message From: Mackenzie B Funai [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Tuesday, August 5, 2008 2:43:42 PM Subject: log text wrap Is there a way to wrap the text in my log. I can't find anything in the appender yet. Mackenzie Funai Developer - Supporting Technologies Computer Sciences Corporation 8616 Freeport Parkway St. 2B Irving, TX 75063 469-499-8521 Computer Sciences Corporation Registered Office: 3170 Fairview Park Drive, Falls Church, Virginia 22042, USA Registered in Nevada, USA No: C-489-59 - This is a PRIVATE message. If you are not the intended recipient, please delete without copying and kindly advise us by e-mail of the mistake in delivery. NOTE: Regardless of content, this e-mail shall not operate to bind CSC to any order or other contract unless pursuant to explicit written agreement or government initiative expressly permitting the use of e-mail for such purpose. -
Re: how to log to differnent textfiles?
You can also place it in another assembly: lockingModel type=Company.Logging.MutexLock, Company.Logging / - Original Message From: [EMAIL PROTECTED] [EMAIL PROTECTED] To: Log4NET User log4net-user@logging.apache.org Sent: Tuesday, May 20, 2008 4:43:47 AM Subject: Re: how to log to differnent textfiles? Hello! I made it. Simple add the code to inside #region Locking Models and activate the new locking with lockingModel type=log4net.Appender.FileAppender+MutexLock / Works great! :-) Thank you very much! [EMAIL PROTECTED] schrieb: Hello! Thanks for the code example. Can you please give me a hint where I should put this peace of code inside the log4net solution? thank you. Ron Grabowski schrieb: I wouldn't recommend using the RollingFileAppender with the MinimalLock. There's no way for one instance of the program to know that another instance has rolled the file. The MinimalLock is slow compared to an ExclusiveLock. The most effecient file based appender across multiple processes would probably be a normal FileAppender with a mutext based lock so the processes can coordinate who is writing to the file. Someone has already implemented such a class: http://www.mail-archive.com/log4net-user@logging.apache.org/msg04116.html That would be a good locking model to support in the next release. - Original Message From: [EMAIL PROTECTED] [EMAIL PROTECTED] To: Log4NET User log4net-user@logging.apache.org Sent: Monday, May 19, 2008 7:53:24 AM Subject: Re: how to log to differnent textfiles? Hello! Thanks for reply! Yes, it works. But when I log many entries in both processes I receive a log4net:ERROR [RollingFileAppender] Unable to acquire lock on file and after that an INTERNAL ERROR. Append is False but OutputFile ... already exists. There is no way to set the logfile path manual? Or can I specify the folder to user data folder? best regards, Mad
Re: how to log to differnent textfiles?
I wouldn't recommend using the RollingFileAppender with the MinimalLock. There's no way for one instance of the program to know that another instance has rolled the file. The MinimalLock is slow compared to an ExclusiveLock. The most effecient file based appender across multiple processes would probably be a normal FileAppender with a mutext based lock so the processes can coordinate who is writing to the file. Someone has already implemented such a class: http://www.mail-archive.com/log4net-user@logging.apache.org/msg04116.html That would be a good locking model to support in the next release. - Original Message From: [EMAIL PROTECTED] [EMAIL PROTECTED] To: Log4NET User log4net-user@logging.apache.org Sent: Monday, May 19, 2008 7:53:24 AM Subject: Re: how to log to differnent textfiles? Hello! Thanks for reply! Yes, it works. But when I log many entries in both processes I receive a log4net:ERROR [RollingFileAppender] Unable to acquire lock on file and after that an INTERNAL ERROR. Append is False but OutputFile ... already exists. There is no way to set the logfile path manual? Or can I specify the folder to user data folder? best regards, Mad
Re: log4net stops logging for apparently no reason
You could leave the internal logs on for a while to try and capture the error again or you could write your own IErrorHandler and send an email when an error occurs: public class EmailOnlyOnceErrorHandler : OnlyOnceErrorHandler { public new void Error(string message, Exception e, ErrorCode errorCode) { base.Error(message, e, errorCode); // TODO: send mail } } Any appender that extends AppenderSkeleton (most of the built-in appenders including FileAppender) has an ErrorHandler property that you can set in the config file: appender name=LogFileAppender type=log4net.Appender.FileAppender errorHandler value=Company.Logging.EmailOnlyOnceErrorHandler, Company.Logging / !-- snip -- /appender Maybe there are issues with ASP.Net spawning a new AppDomain for the application before the old AppDomain has released the exclusive lock on the file. - Original Message From: Seth Milder [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Thursday, May 15, 2008 12:34:06 PM Subject: log4net stops logging for apparently no reason Hi, I was very happy with log4net. Kudos to the developers. However, one day, it inexplicably and silently stopped logging. We are using log4net for our internal SharePoint applications, in case this makes any difference. Here are the relevant parts of my web. config (this has changed a bit since I've been mucking about with it): configuration configSections ... section name=log4net type=log4net.Config.Log4NetConfigurationSectionHandler, log4net requirePermission=false / /configSections ... log4net appender name=LogFileAppender type=log4net.Appender.FileAppender param name=File value=C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS\apps.log / layout type=log4net.Layout.PatternLayout param name=ConversionPattern value=%d [%t] %-5p %c %m%n / /layout /appender root level value=DEBUG / appender-ref ref=LogFileAppender / /root /log4net /configuration I turned on internal logging and I get this: log4net: DefaultRepositorySelector: Assembly [XXX.YYY.ZZZ, Version=1.0.0.0, Culture=neutral, PublicKeyToken=] using repository [log4net-default-repository] and repository type [log4net.Repository.Hierarchy.Hierarchy] log4net: DefaultRepositorySelector: repository [log4net-default-repository] already exists, using repository type [log4net.Repository.Hierarchy.Hierarchy] log4net: DefaultRepositorySelector: Creating repository for assembly [AAA.BBB.CCC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=] log4net: DefaultRepositorySelector: Assembly [AAA.BBB.CCC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=] Loaded From [Global Assembly Cache] log4net: DefaultRepositorySelector: Assembly [AAA.BBB.CCC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=] does not have a RepositoryAttribute specified. log4net: DefaultRepositorySelector: Assembly [AAA.BBB.CCC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=] using repository [log4net-default-repository] and repository type [log4net.Repository.Hierarchy.Hierarchy] Now another server has suffered the same fate and I am getting desperate. Can anyone help? I've googled this to no avail. Thanks for any available guidance! Best, Seth Milder -- Seth Milder AIM: sdmilder Have something to hide? http://securepastebin.com
Re: Problem getting Log4net to work
What does log4net's internal debug message say: http://logging.apache.org/log4net/release/faq.html Have you tried configuring log4net from within the client app's entry point to verify your log4net.config is correct? - Original Message From: Neil Haughton [EMAIL PROTECTED] To: Log4NET User log4net-user@logging.apache.org Sent: Monday, May 12, 2008 11:26:00 AM Subject: Problem getting Log4net to work Can anybody spot what I am doing wrong? I'm probably doing something stupid, but I've been banging my head against this for a few days and am getting no further: I have a solution comprising two projects, a client app and a logger project. The logger project encapsulates calls to log4net. It has a line in its AssemblyInfo file [assembly: log4net.Config.XmlConfigurator(ConfigFile = Log4Net.config, Watch = true)] and static loggers and methods to call various loggers, eg private static readonly ILog bllDebugLog = LogManager.GetLogger(Matrix.Trace); and so on. a Typical logging method in the logger code is public static void Trace(string message) { using (NDC.Push(TRACE)) { bllDebugLog.Debug(message); } } In the same solution I have an application which references the above assembly. The application makes calls to the static log methods, eg logger.Trace(a message); and the log4net.config file is in the executable directory of the application (...\bin\debug and ...\bin\release). It all seems straight out of the book, but try as I might I cannot get log4net to log anything! The bare bones of the log4net.config file is: ?xml version=1.0 encoding=utf-8 ? configuration log4net appender name=RollingFileAppenderROOT type=log4net.Appender.RollingFileAppender file value=c:\logs\MatrixROOT.log / layout type=log4net.Layout.PatternLayout conversionPattern value=%m%newline / /layout appendToFile value=true / maximumFileSize value=100KB / maxSizeRollBackups value=2 / /appender appender name=RollingFileAppenderTRACE type=log4net.Appender.RollingFileAppender file value=c:\logs\MatrixTRACE.log / layout type=log4net.Layout.PatternLayout conversionPattern value=%m%newline / /layout appendToFile value=true / maximumFileSize value=100KB / maxSizeRollBackups value=2 / /appender root appender-ref ref=RollingFileAppenderROOT / /root logger name=Matrix.Trace !--this is for routine debug logging to a file-- level value=DEBUG / appender-ref ref=RollingFileAppenderTRACE / /logger /log4net /configuration TIA Neil
Re: Using log4net.Util.PatternString in a PatternLayout
The PatternString used for the Header and Footer is converted to a string at configuration time using the internal PatternStringConverter class. You can easily write your own PatternLayout: public class HeaderFooterPatternStringLayout : PatternLayout { private PatternString headerPatternString; private PatternString footerPatternString; public override string Header { get { return headerPatternString.Format(); } set { base.Header = value; headerPatternString = new PatternString(base.Header); } } public override string Footer { get { return footerPatternString.Format(); } set { base.Footer = value; footerPatternString = new PatternString(base.Footer); } } } layout type=Company.Logging.HeaderFooterPatternStringLayout, Company.Logging header value=... / footer value=... / conversionPattern value=... / /layout Since you're already going through the trouble of writing a custom PatternLayout I'd go all in and provide default values: public class DefaultHeaderFooterPatternStringLayout : PatternLayout { public const string DEFAULT_HEADER_PATTERN = %newline Trace Opened Local: %date{-MM-dd HH:mm:ss.fff}UTC: %utcdate{-MM-dd HH:mm:ss.fff} %newline; public const string DEFAULT_FOOTER_PATTERN = Trace Closed %date{-MM-dd HH:mm:ss.fff} %newline; public const string DEFAULT_CONVERSION_PATTERN = %d{dd HH:mm:ss.fff} [%4t] %P{instance}::%M - %m%n; private PatternString headerPatternString; private PatternString footerPatternString; public DefaultHeaderFooterPatternStringLayout() : base(DEFAULT_CONVERSION_PATTERN) { headerPatternString = new PatternString(DEFAULT_HEADER_PATTERN); footerPatternString = new PatternString(DEFAULT_FOOTER_PATTERN); } public override string Header { get { return headerPatternString.Format(); } set { base.Header = value; headerPatternString = new PatternString(base.Header); } } public override string Footer { get { return footerPatternString.Format(); } set { base.Footer = value; footerPatternString = new PatternString(base.Footer); } } } so your layout is just: layout type=Company.Logging.DefaultHeaderFooterPatternStringLayout, Company.Logging / I can't think of a good reason why the the Header and Footer properties aren't PatternStrings that are calculated at run-time instead of once at configuration time. - Original Message From: Roy Chastain [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Wednesday, May 7, 2008 8:34:34 AM Subject: Using log4net.Util.PatternString in a PatternLayout I have the following layout defined for a RollingFileAppender (log4Net 1.2.10) layout type=log4net.Layout.PatternLayout param name=Header type=log4net.Util.PatternString value=%newline Trace Opened Local: %date{-MM-dd HH:mm:ss.fff} UTC: %utcdate{-MM-dd HH:mm:ss.fff} %newline / param name=Footer type=log4net.Util.PatternString value= Trace Closed %date{-MM-dd HH:mm:ss.fff} %newline / param name=ConversionPattern value=%d{dd HH:mm:ss.fff} [%4t] %P{instance}::%M - %m%n / /layout The idea is to place the current date and time in the header and footer of each log file as it rolls over. Instead each header and footer receives the same date/time. (The date/time is the date/time the original file was opened.) This action is certainly not what was expected, and I do not believe a useful implementation. Can someone say that the result is has expected and, if so, please give some pointers on how to implement a 'current date/time' for the headers and footers? Thanks -- Roy Chastain
Re: AW: log4net configuration withtou Xml file
I added an overload to BasicConfigurator that accepts more than one appender so you don't have to cast down to the Hierarchy and understand what's going on at that level: https://issues.apache.org/jira/browse/LOG4NET-153 - Original Message From: Knittel Bruno [EMAIL PROTECTED] To: Log4NET User log4net-user@logging.apache.org Sent: Tuesday, May 6, 2008 3:38:15 AM Subject: AW: log4net configuration withtou Xml file Nachricht Hi Everyone, I finally managed to configure log4net through the code, even using multiple appenders. Was not so hard, I just took a look at how the BasicConfigurator, XmlConfigurator and the units tests were written. Follows the piece of code I just ran. It creates a ConsoleAppender as well as a FileAppender. Hope it can help someone. Regards, Bruno using System; using System.Collections.Generic; using System.Windows.Forms; using log4net; using log4net.Appender; using log4net.Repository; using log4net.Repository.Hierarchy; namespace log4nettest { static class Program { /// summary /// The main entry point for the application. /// /summary [STAThread] static void Main() { ConfigureLog(); ILog lLog = LogManager.GetLogger(typeof(Program)); lLog.Debug(Debug); lLog.Error(Error); lLog.Fatal(Fatal); lLog.Info(Info); lLog.Warn(warn); } private static ConsoleAppender GetConsoleAppender() { ConsoleAppender lAppender = new ConsoleAppender(); lAppender.Name = Console; lAppender.Layout = new log4net.Layout.PatternLayout(%date{dd-MM- HH:mm:ss,fff} %5level [%2thread] %message (%logger{1}:%line)%n); lAppender.Threshold = log4net.Core.Level.Error; lAppender.ActivateOptions(); return lAppender; } private static FileAppender GetFileAppender() { FileAppender lAppender = new FileAppender(); lAppender.Name = File; lAppender.AppendToFile = true; lAppender.File = log.txt; lAppender.Layout = new log4net.Layout.PatternLayout(%date{dd-MM- HH:mm:ss,fff} %5level [%2thread] %message (%logger{1}:%line)%n); lAppender.Threshold = log4net.Core.Level.All; lAppender.ActivateOptions(); return lAppender; } private static void ConfigureLog() { Logger root; root = ((Hierarchy)LogManager.GetRepository()).Root; root.AddAppender(GetConsoleAppender()); root.AddAppender(GetFileAppender()); root.Repository.Configured = true; } } } Bruker BioSpinGmbH Bruno Knittel Automation Development Bruker BioSpin GmbH Silberstreifen 76287 Rheinstetten Germany Phone: +49 721 5161-90064 Fax: +49 721 5161-494 [EMAIL PROTECTED] www.bruker-biospin.com Bruker BioSpin GmbH: Sitz der Gesellschaft/Registered Office: Rheinstetten, HRB 102368 Amtsgericht Mannheim Geschäftsführer/Managing Directors: Dr. Bernd Gewiese, Dr. Dieter Schmalbein, Dr. Gerhard Roth Diese E-Mail und alle Anlagen können Betriebs- oder Geschäftsgeheimnisse, oder sonstige vertrauliche Informationen enthalten. Sollten Sie diese E-Mail irrtümlich erhalten haben, ist Ihnen eine Kenntnisnahme des Inhalts, eine Vervielfältigung oder Weitergabe der E-Mail und aller Anlagen ausdrücklich untersagt. Bitte benachrichtigen Sie den Absender und löschen/vernichten Sie die empfangene E-Mail und alle Anlagen. Vielen Dank. This message and any attachments may contain trade secrets or privileged, undisclosed or otherwise confidential information. If you have received this e-mail in error, you are hereby notified that any review, copying or distribution of it and its attachments is strictly prohibited. Please inform the sender immediately and delete/destroy the original message and any copies. Thank you. -Ursprüngliche Nachricht- Von: Radovan Raszka [mailto:[EMAIL PROTECTED] Gesendet: Dienstag, 6. Mai 2008 08:00 An: Log4NET User Betreff: RE: log4net configuration withtou Xml file Hello Bruno, configuring log4net directly from the code is my dream too, but documentation did not give any example how to do this. It is simple if you need to use the only appender - use BasicConfigurator: log4net.Appender.FileAppender fa = new log4net.Appender.FileAppender(); fa.AppendToFile = false; fa.File = ipagent.log; fa.Layout = new log4net.Layout.PatternLayout(%date{dd-MM- HH:mm:ss,fff} %5level [%2thread] %message (%logger{1}:%line)%n); fa.Threshold = log4net.Core.Level.Debug; fa.ActivateOptions(); log4net.Config.BasicConfigurator.Configure(fa); I have this tested
Re: Throttling/Rollup feature in EventLogAppender
It looks like that class was written a while ago so you may already know this...you should be able to extend the built-in ForwardingAppender and let it handle the IAppenderAttachable stuff so the Append methods would look something like this: public class DupeFilteringForwardingAppender : ForwardingAppender { protected override void Append(LoggingEvent loggingEvent) { base.Append(CheckForDupe(loggingEvent)); } protected override void Append(LoggingEvent[] loggingEvents) { ListLoggingEvent filteredLoggingEventList = new ListLoggingEvent(); foreach (LoggingEvent loggingEvent in loggingEvents) { filteredLoggingEventList.AddRange(CheckForDupe(loggingEvent)); } base.Append(filteredLoggingEventList.ToArray()); } // snip } - Original Message From: Jerry Shea [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Saturday, May 3, 2008 12:50:13 AM Subject: Re: Throttling/Rollup feature in EventLogAppender Hi Pranav, James Wilkinson and I worked up some code to do this. See http://markmail.org/message/pahnqti7yq4xoz7m I am currently the bottleneck on this having not responded to James' last message :(. I'll get moving and hopefully we can contribute this code to the community soon. Cheers, Jerry -- Forwarded message -- From: Pranav Varia [EMAIL PROTECTED] To: log4net-user@logging.apache.org log4net-user@logging.apache.org Date: Fri, 2 May 2008 14:00:08 -0700 Subject: Throttling/Rollup feature in EventLogAppender Is there a Throttling feature available or planned in EventLogAppender. If we log to event log a message that could potentially be logged at frequency of one per incoming request to my web application, it could flood the event log with millions of messages if/when things go wrong. If there was a = way to roll them up every x seconds into a single event log message (with a count of how many messages where rolledup), it would be useful to me. Is there any such feature? Or workaround? Regards Pranav
Re: Throttling/Rollup feature in EventLogAppender
It looks like someone has done something similar with the SmtpAppender: http://marc.info/?l=log4net-userm=120887073724259w=2 You could use the BufferingForwardingAppender to capture the messages then send aggregate information when its time to flush the buffer. - Original Message From: Pranav Varia [EMAIL PROTECTED] To: log4net-user@logging.apache.org log4net-user@logging.apache.org Sent: Friday, May 2, 2008 5:00:08 PM Subject: Throttling/Rollup feature in EventLogAppender Is there a Throttling feature available or planned in EventLogAppender. If we log to event log a message that could potentially be logged at frequency of one per incoming request to my web application, it could flood the event log with millions of messages if/when things go wrong. If there was a = way to roll them up every x seconds into a single event log message (with a count of how many messages where rolledup), it would be useful to me. Is there any such feature? Or workaround? Regards Pranav
Re: SmtpAppender not working on 3rd party hosting provider
JIRA is down right now but couldn't you extend SmtpAppender in your own assembly and override the method(s) needed then use the SmtpAppender in your new assembly? I use GoDaddy.com too. I remember SmtpAppender working fine under ASP.Net 1.0. I think it stopped working when I upgraded to ASP.Net 2.0. Thanks for summarizing your research for the list. - Original Message From: Pete Heist [EMAIL PROTECTED] To: Log4NET User log4net-user@logging.apache.org Sent: Wednesday, April 30, 2008 12:59:59 PM Subject: RE: SmtpAppender not working on 3rd party hosting provider Apologies for the list traffic, but this appears to have been fixed by Nicko back in July of 2006: http://issues.apache.org/jira/browse/LOG4NET-79?page=com.atlassian.jira.plug in.system.issuetabpanels:all-tabpanel http://mail-archives.apache.org/mod_mbox/logging-log4net-user/200607.mbox/%3 [EMAIL PROTECTED] and targeted for version 1.2.11, which never came out. I guess I'll have to apply his patch by hand or not use the SmtpAppender under medium trust. thanks, Pete -Original Message- From: Pete Heist [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 30, 2008 6:08 PM To: 'Log4NET User' Subject: RE: SmtpAppender not working on 3rd party hosting provider I found the SecurityException that's causing the SmtpAppender to fail. The stack trace is below. (I wasn't seeing it before as I'd had system.diagnostics redirected to a file, which was also causing a SecurityException that I didn't see.) Anyone know how to solve this one? Things I've tried include: - reading configuration from web.config instead of my separate log4net.config - removing my GlobalContext.Properties settings and use of context properties, thinking that the LinkDemand was happening when log4net was calling my class to get my [%property{CurrentUser}], but apparently it's not - setting [assembly: AllowPartiallyTrustedCallers] on my UserProvider class, which is stuffed into GlobalContext.Properties From the stack, the LinkDemand appears to occur in log4net.Util.LogicalThreadContextProperties.GetProperties(), which likely happens when CallContext.GetData is called(?), but I'm not sure how to get around this. -- Begin Stack Trace -- log4net:ERROR [SmtpAppender] Failed in DoAppend System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException) at System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs, PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Assembly asm, SecurityAction action) at log4net.Util.LogicalThreadContextProperties.GetProperties(Boolean create) at log4net.Core.LoggingEvent.CreateCompositeProperties() at log4net.Core.LoggingEvent.CacheProperties() at log4net.Core.LoggingEvent.FixVolatileData(FixFlags flags) at log4net.Appender.BufferingAppenderSkeleton.Append(LoggingEvent loggingEvent) at log4net.Appender.AppenderSkeleton.DoAppend(LoggingEvent loggingEvent) The action that failed was: LinkDemand The type of the first permission that failed was: System.Security.Permissions.SecurityPermission The Zone of the assembly that failed was: MyComputer -- End Stack Trace -- If there are any suggestions, let me know. thanks, Pete -Original Message- From: Pete Heist [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 30, 2008 4:39 PM To: 'Log4NET User' Subject: RE: SmtpAppender not working on 3rd party hosting provider It's narrowed down a bit. If I set: trust level=Medium/ on my development machine, the SmtpAppender fails silently, while my RollingFileAppenders still work. Incidently, I've got my log4net.config file in a separate file, rather than in my web.config file. This appears to be working OK, but as I've seen a post about log4net configuration and medium trust here: http://blogs.advantaje.com/blog/kevin/Net/2006/06/29/log4Net-and-ASP-Net-Med ium-Trust.html it makes me suspicious. thanks, Pete -Original Message- From: Pete Heist [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 30, 2008 4:09 PM To: 'Log4NET User' Subject: RE: SmtpAppender not working on 3rd party hosting provider Hi Dean, Yes, even if smtpHost is specified in
Re: How to print a tabulator without %tabulator ?
Do you mean a tab character? \t - Original Message From: Alexander Vayman [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Wednesday, April 23, 2008 3:06:04 AM Subject: How to print a tabulator without %tabulator ? .hmmessage P { margin:0px;padding:0px;} body.hmmessage { FONT-SIZE:10pt;FONT-FAMILY:Tahoma;} Hello, there is a very simple thing i dont know how to do: tabulator in conversionPattern value. There is a %newline, but no %tabulator. Is it possible to get the tabulator someway? Thank you, Alexander Connect to the next generation of MSN Messenger Get it now!
Re: Log4Net and Vista logo certification
http://logging.apache.org/log4net/download.html - Original Message From: [EMAIL PROTECTED] [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Tuesday, April 22, 2008 11:01:14 AM Subject: Log4Net and Vista logo certification Hello ! We are going to submit some of our products to the Vista Logo program. These products are using log4net for logging stuff. A test case in the vista logo certification specifies that all delivered dlls must be signed. The version of log4net we have is not currently signed. Is there a way to get a signed dll of your logging solution ? Thank you very much * Atronic Systems - S.A.M. Yohann NICOLAS Software Development Engineer Phone: 133 (internal) Email: mailto: [EMAIL PROTECTED] Web: http://www.atronicsystems.com *
Faster %date{yyyy-MM-dd hh:mm:ss tt} pattern converter
This is a faster pattern converter for the -MM-dd hh:mm:ss tt pattern. I use this primarily with my NHibernate logger in DEBUG mode because I want to see what NHibernate is doing but I don't necessarily care about timings down to the millisecond when its writing out its generated sql and building objects. When I use this pattern converter my app doesn't feel slow when NHibenrate DEBUG logging is enabled: public class NoMillisecondsPatternConverter : PatternLayoutConverter { private long nextSecond; private string cachedTimeStamp; protected override void Convert(TextWriter writer, LoggingEvent loggingEvent) { if (loggingEvent.TimeStamp.Ticks nextSecond) { cachedTimeStamp = loggingEvent.TimeStamp.ToString(-MM-dd hh:mm:ss tt); nextSecond = loggingEvent.TimeStamp.Ticks + TimeSpan.TicksPerSecond; // ??? } writer.Write(cachedTimeStamp); } } Here's a simplistic benchmark that compares the two: class Program { static void Main(string[] args) { runner(new SimpleDateFormatter(-MM-dd hh:mm:ss tt)); runner(new NoMillisecondsDateFormatter()); } public static void runner(IDateFormatter dateFormatter) { StubTextWriter writer = new StubTextWriter(); Console.Write(dateFormatter + : ); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); for (int i = 0; i 1000; i++) { dateFormatter.FormatDate(DateTime.Now, writer); } stopwatch.Stop(); Console.WriteLine(stopwatch.ElapsedMilliseconds); } } log4net.DateFormatter.SimpleDateFormatter: 17185 ConsoleApplication1.NoMillisecondsDateFormatter: 3561 NoMillisecondsDateFormatter is about 80% faster by not showing the milliseconds. This is how you use the code: layout type=log4net.Layout.PatternLayout converter name value=date / type value=Company.Logging.NoMillisecondsPatternConverter, Company.Logging / /converter conversionPattern value=%5level %date (%logger) - %message%newline / /layout or you could create a custom pattern layout to more easily share the converter: layout type=Company.Logging.MoMillisecondsPatternLayout conversionPattern value=%5level %date (%logger) - %message%newline / /layout Log4net uses a similiar caching approach with the built-in date formatters: %date{DATE}, %date{ABSOLUTE}, etc. Those are much faster than using your own predefined layout because they cache most of the slow changing components of the logging event's TimeStamp like year, month, day, hour, minute, and second then only calculate the millisecond when generating the string. This is interesting article about faster ways of formatting time by calculating the offsets manually: Performance Quiz: Fastest way to format time http://geekswithblogs.net/akraus1/archive/2006/04/23/76146.aspx
Re: System.Reflection.MethodBase.GetCurrentMethod ()' threw an exception of type 'System.ArSystem.Reflection.MethodBase
System.Reflection.MethodBase.GetCurrentMethod() isn't from the log4net assembly so this isn't a log4net error. What is your code trying to do? The usage for logging exceptions is usually: log.Error(ex) where the current Type has already been used to create the ILog instance. This works for me: try { throw new Exception(); } catch (Exception ex) { string type = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(); Console.WriteLine(type); } - Original Message From: aus1977 [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Thursday, March 27, 2008 11:47:39 AM Subject: System.Reflection.MethodBase.GetCurrentMethod ()' threw an exception of type 'System.ArSystem.Reflection.MethodBase I am trying to use log4net in next manner : LogException(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(),ex) and i am getting System.Reflection.MethodBase.GetCurrentMethod ()' threw an exception of type 'System.ArSystem.Reflection.MethodBase somebody help me . -- View this message in context: http://www.nabble.com/System.Reflection.MethodBase.GetCurrentMethod-%28%29%27-threw-an-exception-of-type-%27System.ArSystem.Reflection.MethodBase-tp16326610p16326610.html Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Log4Net stopping
Does logging stop on both the ConsoleAppender and the RollingLogFileAppender? - Original Message From: Robin Shahan [EMAIL PROTECTED] To: Log4NET User log4net-user@logging.apache.org Sent: Wednesday, March 19, 2008 2:40:40 PM Subject: RE: Log4Net stopping font-face { font-family:Cambria Math;} font-face { font-family:Calibri;} font-face { font-family:Tahoma;} P.MsoNormal { FONT-SIZE:11pt;MARGIN:0in 0in 0pt;FONT-FAMILY:Calibri, sans-serif;} LI.MsoNormal { FONT-SIZE:11pt;MARGIN:0in 0in 0pt;FONT-FAMILY:Calibri, sans-serif;} DIV.MsoNormal { FONT-SIZE:11pt;MARGIN:0in 0in 0pt;FONT-FAMILY:Calibri, sans-serif;} A:link { COLOR:blue;TEXT-DECORATION:underline;} SPAN.MsoHyperlink { COLOR:blue;TEXT-DECORATION:underline;} A:visited { COLOR:purple;TEXT-DECORATION:underline;} SPAN.MsoHyperlinkFollowed { COLOR:purple;TEXT-DECORATION:underline;} P.MsoAcetate { FONT-SIZE:8pt;MARGIN:0in 0in 0pt;FONT-FAMILY:Tahoma, sans-serif;} LI.MsoAcetate { FONT-SIZE:8pt;MARGIN:0in 0in 0pt;FONT-FAMILY:Tahoma, sans-serif;} DIV.MsoAcetate { FONT-SIZE:8pt;MARGIN:0in 0in 0pt;FONT-FAMILY:Tahoma, sans-serif;} SPAN.BalloonTextChar { FONT-FAMILY:Tahoma, sans-serif;} SPAN.EmailStyle19 { COLOR:windowtext;FONT-FAMILY:Calibri, sans-serif;} SPAN.EmailStyle20 { COLOR:#5f497a;FONT-FAMILY:Calibri, sans-serif;} SPAN.EmailStyle21 { COLOR:#5f497a;FONT-FAMILY:Calibri, sans-serif;} .MsoChpDefault { FONT-SIZE:10pt;} DIV.Section1 { } When I turn on the internal debugging, the logging works every time. When I turn it off, it doesn't. I'm enabled this feature following the instructions in the link below. Does anybody have any ideas at all? Thanks, Robin From: Robin Shahan [mailto:[EMAIL PROTECTED] Sent: Wed 3/19/2008 10:51 AM To: Log4NET User; Log4NET User Subject: RE: Log4Net stopping The upload is spun off in a separate thread. We had another occurrence this morning where it stopped logging as soon as the user authenticated. This is not in a separate thread. I found this link, and it has some info about running internal debugging while logging; has anyone tried this? http://logging.apache.org/log4net/release/faq.html Thanks, Robin From: Dean Fiala [mailto:[EMAIL PROTECTED] Sent: Wed 3/19/2008 9:13 AM To: 'Log4NET User' Subject: RE: Log4Net stopping Hmmm, doesn't sound like you are bombarding the logger, but a few large file tests would be my next step. By large messages, I meant a couple of kilobytes, that's only really variably sized bit of the log entry. Another question. Does this file upload happen on the application's main thread, or is it spun off in a separate thread? Finally, is the rolling file log being accessed by anything else in the application? Dean From: Robin Shahan [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 19, 2008 12:01 PM To: Log4NET User Subject: RE: Log4Net stopping It uploads the file in chunks, so it prints out a log entry with each chunk. So maybe it’s not “a lot of logging” by other people’s standards, but it’s probably where the most logging occurs in our app. It depends on the size of the file. We’re testing with pretty small ones (no patience), so the last one I did was 156 lines of logging. It is just statements like “hitting the refresh code”, “posting chunk”, “chunk #23 posted”, “chunk 23 successful”. It prints the date/time and routing that logged the entry. As far as I know, we don’t have any large individual messages (how do you define large?), but I’ll see. It’s weird because as far as I know, that code hasn’t been mucked with, and it has been working just fine. Or so we think. Luckily, we use TFS, so I can tell if someone’s changed it, and if so, how. Thanks, Robin From: Dean Fiala [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 19, 2008 8:38 AM To: 'Log4NET User' Subject: RE: Log4Net stopping OK, Hard to tell how it is related without seeing what you are logging, but since that is your best guess, might as well follow up in that direction. Can you quantify a lot of logging? Are you attempting to log a large section of the file that is being uploaded? Or some other large individual message during the process? That's where I'd look since it seems to be appender indepenent. Dean From: Robin Shahan [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 19, 2008 11:12 AM To: Log4NET User Subject: RE: Log4Net stopping The file is being uploaded to our servers via web services. I don’t see how it can be related (it’s not a new feature), but that is the pattern we’re seeing -- logging stops for some people after they’ve uploaded. One thing to note: There is a lot of logging done during the upload process. One other thing – I remembered last night that I’ve seen this in one other case. I put some logging statements in this click event in a user control once, and it wouldn’t output the statements. I ended up putting in messageboxes to get the information I was looking for. And the other programmer who has seen this problem
Re: Is there a log reloaded event?
http://logging.apache.org/log4net/release/sdk/log4net.Repository.ILoggerRepository.ConfigurationChanged.html - Original Message From: Rob Prouse [EMAIL PROTECTED] To: log4net-user@logging.apache.org log4net-user@logging.apache.org Sent: Thursday, March 13, 2008 4:09:11 PM Subject: Is there a log reloaded event? We have converted some of our legacy unmanaged code to use log4net through wrapper classes. For efficiency, we cache the various IsEnabled properties that our unmanaged code uses. Because it is cached, we need to know when XmlConfigurator reloads a changed configuration file so that we can clear our cache. I have searched the SDK docs, but I couldn't find any events that I could subscribe to. Am I missing something or does anyone have a suggestion how I can determine when the log configuration is loaded/reloaded? Thanks in advance... Rob Prouse Framework Developer Ivara
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 [EMAIL PROTECTED] To: log4net-user@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.
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 [EMAIL PROTECTED] To: log4net-user@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 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 appender name=LongTermRolling type=log4net.Appender.RollingFileAppender param name=File value=C:\\temp\\Logs\\MyApp\\LongTerm\\log/ param name=LockingModel value=MinimalLock/ param name=RollingStyle value=Composite/ param name=DatePattern value=-MM/ param name=MaximumFileSize value=30MB/ param name=MaxSizeRollBackups value=6/ param name=StaticLogFileName value=false/ param name=CountDirection value=1/ layout type=log4net.Layout.PatternLayout,log4net param name=ConversionPattern value=%date,%property{ApplicationName},%property{log4net:HostName},%lev el,%thread,%logger{1},%property{SourceIp},%property{HttpHost},%property{ UrlPath},%property{QueryString},%property{SoapAction},%property{Code},%m essage%n/ /layout /appender
Re: log4net and IIS problems
I thought there was something like this already in place but I checked just now and the LockingModelBase classes don't have any retry code; they try once then error if the file can't be opened. It would be useful to allow for a defined set of open attempts at defined intervals on FileAppender derived classes. This is locking model specific and not LockingStream specific because LockingStream delegates the opening of files to a locking mode. Adding the retry code would also give us an opportunity to move the duplicate impersonation code out of each of the LockingModelBase inheritors and into LockingModelBase. - Original Message From: Morten Andersen [EMAIL PROTECTED] To: Log4NET User log4net-user@logging.apache.org Sent: Thursday, February 28, 2008 5:07:43 AM Subject: RE: log4net and IIS problems !-- _filtered {font-family:Cambria Math;panose-1:2 4 5 3 5 4 6 3 2 4;} _filtered {font-family:Calibri;panose-1:2 15 5 2 2 2 4 3 2 4;} _filtered {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm;margin-bottom:.0001pt;font-size:11.0pt;font-family:Calibri, sans-serif;} a:link, span.MsoHyperlink {color:blue;text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {color:purple;text-decoration:underline;} p.msochpdefault, li.msochpdefault, div.msochpdefault {margin-right:0cm;margin-left:0cm;font-size:10.0pt;font-family:Times New Roman, serif;} span.epoststil17 {font-family:Calibri, sans-serif;color:windowtext;} span.emailstyle18 {font-family:Calibri, sans-serif;color:#1F497D;} span.EpostStil20 {font-family:Calibri, sans-serif;color:#1F497D;} .MsoChpDefault {font-size:10.0pt;} _filtered {margin:70.85pt 70.85pt 70.85pt 70.85pt;} div.Section1 {} -- Would it be possible to add some retry mechanism to the appender? If the appender fails to open the file it may try again after x seconds. Some log data may be lost but for me this is ok as long as it works most of the time. Fra: Ron Grabowski[mailto:[EMAIL PROTECTED] Sendt: 28. februar 2008 00:39 Til: Log4NET User Emne: Re: log4net and IIS problems Didn't quite finish my thought...I meant to say that we could add an EventLogErrorHandler to catch edge cases like this. To address the underlying problem, someone posted some code to the control inter-process/AppDomain locking using a Mutext. My concern is what happens if the terminal AppDomain requests the Mutex then is forceably killed? According the Mutex docs on MSDN an Exception will be thrown when the new AppDomains attempts to open that Mutext.
Re: log4net and IIS problems
The Mutext stuff works great for allowing two AppDomains (i.e. two .NET processes) to write to the same file without having to open and close the file after each write. If IIS forceably kills the old AppDomain becuase its taking too long to finish its requests will the new AppDomain get an AbadonedThreadException because the old AppDomain has the Mutext while it was writing to the file. I posted some additional thoughts on the issue here: http://www.ayende.com/Blog/archive/2008/02/28/The-mysterious-life-of-mutexes.aspx#feedback I'm thinking adding in file open retries would a less hetic approach than tracking down the relationship between IIS, AppDomain resets, process termination, finalizers, and Mutexes. - Original Message From: Erich Eichinger [EMAIL PROTECTED] To: Log4NET User log4net-user@logging.apache.org Sent: Thursday, February 28, 2008 6:06:21 AM Subject: RE: log4net and IIS problems Honestly I didn't do it in .NET yet, but from Win32 API I remember, that there was some OpenOrCreate Option for CreateMutex(). The return value of the function indicated, wheter the Mutex was newly created or just opened. I think there is some similar option in .NET, which at least allows for communication between the 2 processes. Maybe an option to defer persisting LogEvents until all Appenders are ready might be a better idea? In this case the new AppDomain would cache all LogEvents in memory until they can be appended. -Erich From: Ron Grabowski [mailto:[EMAIL PROTECTED] Sent: Thu 2008-02-28 00:38 To: Log4NET User Subject: Re: log4net and IIS problems Didn't quite finish my thought...I meant to say that we could add an EventLogErrorHandler to catch edge cases like this. To address the underlying problem, someone posted some code to the control inter-process/AppDomain locking using a Mutext. My concern is what happens if the terminal AppDomain requests the Mutex then is forceably killed? According the Mutex docs on MSDN an Exception will be thrown when the new AppDomains attempts to open that Mutext. - Original Message From: Ron Grabowski [EMAIL PROTECTED] To: Log4NET User log4net-user@logging.apache.org Sent: Wednesday, February 27, 2008 6:04:19 PM Subject: Re: log4net and IIS problems Common was maybe a bad choice of words. If its reproducable - Original Message From: Walden H. Leverich [EMAIL PROTECTED] To: Log4NET User log4net-user@logging.apache.org Sent: Wednesday, February 27, 2008 4:07:26 PM Subject: RE: log4net and IIS problems Is this is a common problem? Yup. I know I've run into it a few of times. Of course, since log4net will fail silently (a good thing) it may be even more prevalent that I think, after all, how many people will know they're missing log entries? -- Walden H Leverich III Tech Software (516) 627-3800 x3051 [EMAIL PROTECTED] http://www.TechSoftInc.com Quiquid latine dictum sit altum viditur. (Whatever is said in Latin seems profound.)
Re: The current target framework (Microsoft .NET Framework 3.5) is not supported by log4net
I added support for 3.0 and 3.5 to the build scripts. log4net doesn't use any 3.0 or 3.5 specific code at the moment. The existing .NET 2.0 assemblies are the best choice for 3.0 and 3.5. I think there's a bug in the latest nant beta where a 3.5 compile actually uses the 2.0 System assemblies. - Original Message From: Mike Baker [EMAIL PROTECTED] To: log4net-user@logging.apache.org Sent: Wednesday, February 6, 2008 10:07:28 PM Subject: The current target framework (Microsoft .NET Framework 3.5) is not supported by log4net !-- /* 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;} span.EmailStyle18 {font-family:Arial;color:navy;} _filtered {margin:1.0in 1.25in 1.0in 1.25in;} div.Section1 {} -- I have recently installed Visual Studio 2008 which uses Microsoft .NET Framework 3.5. When I tried to build log4net, I got the message “The current target framework (Microsoft .NET Framework 3.5) is not supported by log4net.” Is there a workaround? If not, when will 3.5 be supported by log4net? Thanks, -Mike
Re: log4net and IIS problems
If one AppDomain is going away and one is coming online I suspect it'll be difficult to coordinate them talking to each other. Is this is a common problem? - Original Message From: Erich Eichinger [EMAIL PROTECTED] To: Log4NET User log4net-user@logging.apache.org; Log4NET User log4net-user@logging.apache.org Sent: Wednesday, February 27, 2008 2:29:17 PM Subject: RE: log4net and IIS problems As AppDomains are completely isolated from each other, it needs some IPC mechanism for this. A common solution on windows is to create a named Mutex or a named Event as named objects are visible across multiple processes on a machine. -Erich From: Ron Grabowski [mailto:[EMAIL PROTECTED] Sent: Wed 2008-02-27 08:53 To: Log4NET User Subject: Re: log4net and IIS problems I wonder if there's any way for the two AppDomains to be aware of each other... - Original Message From: Morten Andersen [EMAIL PROTECTED] To: Log4NET User log4net-user@logging.apache.org Sent: Tuesday, February 26, 2008 8:14:10 AM Subject: log4net and IIS problems !-- _filtered {font-family:Cambria Math;} _filtered {font-family:Calibri;} p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm;margin-bottom:.0001pt;font-size:11.0pt;font-family:Calibri, sans-serif;} a:link, span.MsoHyperlink {color:blue;text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {color:purple;text-decoration:underline;} span.EpostStil17 {font-family:Calibri, sans-serif;color:windowtext;} .MsoChpDefault {} _filtered {margin:70.85pt 70.85pt 70.85pt 70.85pt;} div.Section1 {} -- Hi I am using log4net on my asp.net web page hosted at an IIS server. This seems to work just fine until I do some changes in the source. Since asp.net runs as a shadow copy, changes will be compiled on the next request after the change was made. I guess this causes the log manager to duplicate itself, and the second one will not have write access to the log files. Since the old app domain will not die before all the requests are completed, the new log manager must wait for this pool to die before enabling the appenders. An alternative solution can be that the log manager retries to create the appenders if it fails. Maybe it already exist a solution for this problem? Best regards, Morten Andersen