logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dean Fiala" <dfi...@celadonlabs.com>
Subject RE: Windows Service console output
Date Thu, 07 Sep 2006 15:36:20 GMT
Debug.Write Line is working because it is attaching to the process via the
CLR, it is not running under the context of the service as the appenders
are.  As such, I suspect that you will not be able to make this work, but
will interested if someone can show differently.

This link is pretty informative on the limitations of a service
communicating via a user interface.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
vbconintroductiontontserviceapplications.asp

-----Original Message-----
From: Joe Waldner [mailto:jwaldner@amtelco.com] 
Sent: Thursday, September 07, 2006 11:24 AM
To: Log4NET User
Subject: RE: Windows Service console output

I suspect that it should work since the Debug writelinw works fine, it is
kind of nice to have all that info there. I am replacing the .net trace
stuff  with log4net and so far that is the only thing I can't do that I did
before. 

-----Original Message-----
From: Dean Fiala [mailto:dfiala@celadonlabs.com]
Sent: Thursday, September 07, 2006 10:13 AM
To: 'Log4NET User'
Subject: RE: Windows Service console output

I think this just has to do with the nature of Windows services.  A service
does not expect nor need to have a logged-in user to work, hence it does not
have the same access to the user interface outputs that a normal windows exe
has.  This is the same reason you can't pop up a message dialog from a
windows service.

If you really want to see what is going on interactively, you can use the
UDP appender and a log Viewer such as NetLogClient.  This is what I use when
I need to see a sevrice's log in realtime.

HTH,

Dean Fiala

Chief Technology Officer
Celadon Laboratories, Inc.
http://www.celadonlabs.com

Microsoft MVP

-----Original Message-----
From: Joe Waldner [mailto:jwaldner@amtelco.com]
Sent: Thursday, September 07, 2006 11:03 AM
To: log4net-user@logging.apache.org
Subject: Windows Service console output

Log4net 114322
Platform .Net framework 1.1 VS 2003

I have a windows service and I am logging events to a file and a console
appender. Log4net is watching the app config file. (using an attribute) The
File appenders work fine but I get no events in the output window.
(The console appender works fine when I debug an application. If I run my
service like an exe (by creating a new instance of the service and running
OnStart), the console output shows up). It is only when I attach the
debugger to a running service that the console appender does not work.
The
file appenders do, thw watching works as well.  The
System.Diagnostics.Debug.Writeline does show up. Also I have an install
program for the service so that it is installed in an application directory
not in the funky obj\\Debug directory it runs from when you use the command
line installer... What am I MISSING? 

This is my config file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
		<section name="log4net"
	
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections> <log4net>
		<appender name="StandardAppender"
type="log4net.Appender.FileAppender">
			<!--To change the file this level of logging goes to
change the File value-->
			<param name="File"
value="C:\Log4netRedAlertLog.txt" />
			<param name="AppendToFile" value="true" />
			<layout type="log4net.Layout.PatternLayout">
				<conversionPattern value="%date{MM/dd/yy
HH:mm:ss:fff} [%thread] %-5level %logger [%property{Switch}]
[%property{Cid}] - %message%newline" />
			</layout>
			<filter type="log4net.Filter.LevelRangeFilter">
				<!--Set the filter for this appender
here-->
				<levelMin value="DEBUG" />
				<levelMax value="FATAL" />
			</filter>
		</appender>
		<appender name="ConsoleAppender"
type="log4net.Appender.ConsoleAppender">
		<layout type="log4net.Layout.PatternLayout">
			<conversionPattern value="%date{MM/dd/yy
HH:mm:ss:fff} [%thread] %-5level %logger [%property{Switch}]
[%property{Cid}] - %message%newline" />
		</layout>
		<filter type="log4net.Filter.LevelRangeFilter">
			<!--Set the filter for this appender here-->
			<levelMin value="DEBUG" />
			<levelMax value="FATAL" />
		</filter>
		</appender>
		<appender name="ExceptionAppender"
type="log4net.Appender.FileAppender">
			<!--To change the file this level of logging goes to
change the File value-->
			<param name="File"
value="C:\RedAlertExceptions.txt" />
			<param name="AppendToFile" value="true" />
			<layout type="log4net.Layout.PatternLayout">
				<conversionPattern value="%date{MM/dd/yy
HH:mm:ss:fff} [%thread] %-5level %logger [%property{Switch}]
[%property{Cid}] %newline%exception" />
			</layout>
			<filter type="log4net.Filter.LevelRangeFilter">
				<!--Set the filter for this appender
here-->
				<levelMin value="ERROR" />
				<levelMax value="FATAL" />
			</filter>
		</appender>
		<root>
			<level value="DEBUG" />
			<!--To remove an appender from log4net logger
comment the appender-ref line-->
			<appender-ref ref="StandardAppender" />
			<appender-ref ref="ExceptionAppender" />
			<appender-ref ref="ConsoleAppender" />
		</root>
	</log4net>	
</configuration>










Mime
View raw message