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:[EMAIL PROTECTED] 
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>






Reply via email to