logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From harry.dougl...@pnc.com
Subject RE: Log4net in a windows service
Date Thu, 09 Oct 2008 17:59:11 GMT
Jeegnesh,

You need to put add the following line in the AssemblyInfo.cs file of your
windows service project:

[assembly: log4net.Config.DOMConfigurator(Watch = true)]

Your log should then appear in the installation folder containing that
contains your windows service EXE based on what you put inside your
App.config.  This would be wherever you installed it on the server root
drive (C:\) since a windows service is put inside the registry.

--Harry



                                                                           
             "Jeegnesh Sheth"                                              
             <jsheth@src-solut                                             
             ions.com>                                                  To 
                                       "Log4NET User"                      
             10/03/2008 10:39          <log4net-user@logging.apache.org>   
             AM                                                         cc 
                                                                           
                                                                   Subject 
             Please respond to         RE: Log4net in a windows service    
              "Log4NET User"                                               
             <log4net-user@log                                             
             ging.apache.org>                                              
                                                                           
                                                                           
                                                                           




It is local to the service and is placed in c:\program
files\myservice\log4net.dll

Yes I enabled the internal debugging and added the section to write to file
at c:\temp\log4nettest.txt and nothing is created

From: CLaco@SummitRacing.com [mailto:CLaco@SummitRacing.com]
Sent: Friday, October 03, 2008 10:38 AM
To: log4net-user@logging.apache.org
Subject: RE: Log4net in a windows service

Had you tried enabling lob4net debugging?

Is log4net local  to your service dll, or do you have it installed itno the
GAC?


 From: Jeegnesh Sheth [mailto:jsheth@src-solutions.com]
 Sent: Friday, October 03, 2008 10:30 AM
 To: Log4NET User
 Subject: RE: Log4net in a windows service
 Chris,
  My config file has the same name myservice.dll.config and I was hoping
 that the same attributes you have would work.

 From: CLaco@SummitRacing.com [mailto:CLaco@SummitRacing.com]
 Sent: Friday, October 03, 2008 10:27 AM
 To: log4net-user@logging.apache.org
 Subject: RE: Log4net in a windows service

 I run a service with log4net just fine using:



 <Assembly: log4net.Config.XmlConfigurator(Watch:=True)>


 The app.config nithe service project get's turned into
 myservice.dll.config that sites beside of myservice.dll.


 For me, it just works.

 -=Chris

 From: Jeegnesh Sheth [mailto:jsheth@src-solutions.com]
 Sent: Friday, October 03, 2008 10:21 AM
 To: Log4NET User
 Subject: RE: Log4net in a windows service
 Radovan,
  Can you explain:
 I prefer configure log4net using app.config file or by special xml file,
 whose location can be got using service's EXE location
 (Assembly.GetExecutingAssembly().Location)

 In my test app, which had an APP.config, when I called my logging DLL, the
 right appender would get called I assumed by the attribute
 [Assembly: log4net.Config.XmlConfigurator(ConfigFile:=
 "mywindowsservice.dll.config", Watch:=True)]

 If I use a special file, and I get the the Assembly executing path, how
 would I pass this information down to log4net dll, so that the right
 appender is called.


 From: Radovan Raszka [mailto:raszka@hasam.cz]
 Sent: Friday, October 03, 2008 10:19 AM
 To: Log4NET User
 Subject: RE: Log4net in a windows service

 Hello,
 problem is usually caused by wrong config file location. If you run
 windows service, then service's current directory is
 %systemroot%\system32, not directory, where service's EXE is located on
 the harddisk. Because your config file is referenced by relative path, it
 can be searched in wrong location.
 I prefer configure log4net using app.config file or by special xml file,
 whose location can be got using service's EXE location
 (Assembly.GetExecutingAssembly().Location)
 Radovan Raszka


       From: Jeegnesh Sheth [mailto:jsheth@src-solutions.com]
       Sent: Friday, October 03, 2008 3:58 PM
       To: log4net-user@logging.apache.org
       Subject: Log4net in a windows service
       Hi,
       I have a logging DLL which uses log4net to log to a database. I have
       c# application which calls this logging DLL and log to the database.
       Within my logging DLL I perform additional work and hence it acts as
       a wrapper for log4net.

       In my C# windows service project, in assemblyinfo.cs I added

       Assembly: log4net.Config.XmlConfigurator(ConfigFile:=
       "mywindowsservice.dll.config", Watch:=True)

       This config file is where I set the appeneder. If I run my unit test
       it seems to work but it does not work in as a windows service. I am
       using system admin privileges so it is not an issue of previlige.

       Any thoughts?


The contents of this email are the property of PNC. If it was not addressed to you, you have
no legal right to read it. If you think you received it in error, please notify the sender.
Do not forward or copy without permission of the sender. This message may contain an advertisement
of a product or service and thus may constitute a commercial electronic mail message under
US Law. The postal address for PNC is 249 Fifth Avenue, Pittsburgh, PA 15222. If you do not
wish to receive any additional advertising or promotional messages from PNC at this e-mail
address, click here to unsubscribe. https://pnc.p.delivery.net/m/u/pnc/uni/p.asp By unsubscribing
to this message, you will be unsubscribed from all advertising or promotional messages from
PNC. Removing your e-mail address from this mailing list will not affect your subscription
to alerts, e-newsletters or account servicing e-mails.

Mime
View raw message