tinhuty he | 1 Jun 2006 23:04
Picon
Favicon

NDC and MDC fields logged as (null)

I am using the 1.2.10. The NDC and MDC fields are logged in file as (null) 
if they are no value. Are they supposed to just log empty string if there 
are no values?

Thanks.

___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

Steve Whitley | 8 Jun 2006 00:02

problems with windows service

Hello,

I have created a windows service, installed it to use the (at first) the 
local system admin account, then the local system account.  I have 
verified that I have the necessary permissions (by simply creating a 
file & writing to it), but log4net is showing Is...Enabled = false on 
all levels.

my config looks like this:

<configuration>
   <configSections>
       <section
             name="log4net"
             type="System.Configuration.IgnoreSectionHandler" />
   </configSections>
   <appSettings>
      <!-- other settings ->
   </appSettings>
   <log4net>
       <appender
             name="RollingLogFileAppender"
             type="log4net.Appender.RollingFileAppender">
           <file
value="${windir}/System32/LogFiles/CompanyName/ServiceName/ServiceName.log" 
/>
           <appendToFile value="true" />
           <rollingStyle value="Date" />
           <datePattern value="yyyy-MM-dd" />
           <staticLogFileName value="true" />
(Continue reading)

Wayne Bradney | 8 Jun 2006 00:04
Favicon

Logging Thread Context Properties

I must be missing something here I’m trying to setup a thread property in my background thread such that my appender can inspect the property when an event is logged:

 

The thread does this:

 

log4net.ThreadContext.Properties["ThreadTaskDescription"] = “<some string>”;

log.Info(“Some message”);

 

 

In the appender, when I look at the Properties property of the LoggingEvent (“Some message”), it never has any properties at all.

 

Am I doing this right?

 

WMB

 

Picon
Favicon

RE: problems with windows service

I think you are missing this in the AssemblyInfo.VB
<Assembly: log4net.Config.DOMConfigurator(ConfigFile:="log4net.config.xml", Watch:=True)> 

-----Original Message-----
From: Steve Whitley [mailto:steve <at> nullfx.com]
Sent: Wednesday, June 07, 2006 6:03 PM
To: 'Log4NET User'
Subject: problems with windows service

Hello,

I have created a windows service, installed it to use the (at first) the 
local system admin account, then the local system account.  I have 
verified that I have the necessary permissions (by simply creating a 
file & writing to it), but log4net is showing Is...Enabled = false on 
all levels.

my config looks like this:

<configuration>
   <configSections>
       <section
             name="log4net"
             type="System.Configuration.IgnoreSectionHandler" />
   </configSections>
   <appSettings>
      <!-- other settings ->
   </appSettings>
   <log4net>
       <appender
             name="RollingLogFileAppender"
             type="log4net.Appender.RollingFileAppender">
           <file
value="${windir}/System32/LogFiles/CompanyName/ServiceName/ServiceName.log" 
/>
           <appendToFile value="true" />
           <rollingStyle value="Date" />
           <datePattern value="yyyy-MM-dd" />
           <staticLogFileName value="true" />
           <layout type="log4net.Layout.PatternLayout">
               <header value="[Header]&#13;&#10;" />
               <footer value="[Footer]&#13;&#10;" />
               <conversionPattern value="...(removed for email)" />
           </layout>
       </appender>
       <root>
           <level value="ALL" />
           <appender-ref ref="RollingLogFileAppender" />
       </root>
   </log4net>
</configuration>

I have the assembly level attribute to look for the config info in 
AssemblyInfo.cs

using log4net.Config;

[assembly: XmlConfigurator(Watch=true)]

If I run the executable as a normal executable, all logging happens as 
it should, but when it runs as a service nothing happens (debugging 
shows that's because the Is...Enabled is false).

anything I've left out that would enable my service to log?

thanks,
Steve

Steve Whitley | 8 Jun 2006 00:33

Re: problems with windows service

DOMConfiguratorAttribute has been depreciated for 
XmlConfiguratorAttribute, but by specifying my config file (Thanks!) 
things are working now.

My "AssemblyName" and "default namespace" are different, which is why 
I'm guessing the config wasnt getting loaded.

Thanks!
--Steve

Bejugam, Raghavendra (GE Comm Fin, non-ge) wrote:

>I think you are missing this in the AssemblyInfo.VB
><Assembly: log4net.Config.DOMConfigurator(ConfigFile:="log4net.config.xml", Watch:=True)> 
>
>-----Original Message-----
>From: Steve Whitley [mailto:steve <at> nullfx.com]
>Sent: Wednesday, June 07, 2006 6:03 PM
>To: 'Log4NET User'
>Subject: problems with windows service
>
>
>Hello,
>
>I have created a windows service, installed it to use the (at first) the 
>local system admin account, then the local system account.  I have 
>verified that I have the necessary permissions (by simply creating a 
>file & writing to it), but log4net is showing Is...Enabled = false on 
>all levels.
>
>my config looks like this:
>
><configuration>
>   <configSections>
>       <section
>             name="log4net"
>             type="System.Configuration.IgnoreSectionHandler" />
>   </configSections>
>   <appSettings>
>      <!-- other settings ->
>   </appSettings>
>   <log4net>
>       <appender
>             name="RollingLogFileAppender"
>             type="log4net.Appender.RollingFileAppender">
>           <file
>value="${windir}/System32/LogFiles/CompanyName/ServiceName/ServiceName.log" 
>/>
>           <appendToFile value="true" />
>           <rollingStyle value="Date" />
>           <datePattern value="yyyy-MM-dd" />
>           <staticLogFileName value="true" />
>           <layout type="log4net.Layout.PatternLayout">
>               <header value="[Header]&#13;&#10;" />
>               <footer value="[Footer]&#13;&#10;" />
>               <conversionPattern value="...(removed for email)" />
>           </layout>
>       </appender>
>       <root>
>           <level value="ALL" />
>           <appender-ref ref="RollingLogFileAppender" />
>       </root>
>   </log4net>
></configuration>
>
>
>I have the assembly level attribute to look for the config info in 
>AssemblyInfo.cs
>
>using log4net.Config;
>
>[assembly: XmlConfigurator(Watch=true)]
>
>If I run the executable as a normal executable, all logging happens as 
>it should, but when it runs as a service nothing happens (debugging 
>shows that's because the Is...Enabled is false).
>
>anything I've left out that would enable my service to log?
>
>thanks,
>Steve
>
>  
>

tinhuty he | 8 Jun 2006 03:05
Picon
Favicon

how to set property for application level

How can I set a property in application level so that all logs produced from 
that application will have this property in log file, including all logs 
produced from other assemblies used by this application?

For example I want to all my log has an property "appname" to stored the 
value of application name. I tried to set an application name:
ThreadContext.Properties["appname"] = "App1";
This doesn't work as what I wanted. Some of the log entries don't have this 
property.

How should I approach it?

Thanks.

___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

_________________________________________________________________
On the road to retirement? Check out MSN Life Events for advice on how to 
get there! http://lifeevents.msn.com/category.aspx?cid=Retirement

Ron Grabowski | 8 Jun 2006 03:51
Picon
Favicon

Re: how to set property for application level

Have you tried the GlobalContext?

--- tinhuty he <tinhuty <at> hotmail.com> wrote:

> How can I set a property in application level so that all logs
> produced from 
> that application will have this property in log file, including all
> logs 
> produced from other assemblies used by this application?
> 
> For example I want to all my log has an property "appname" to stored
> the 
> value of application name. I tried to set an application name:
> ThreadContext.Properties["appname"] = "App1";
> This doesn't work as what I wanted. Some of the log entries don't
> have this 
> property.
> 
> How should I approach it?
> 
> Thanks.

Sam Carleton | 9 Jun 2006 20:30
Favicon
Gravatar

OutputDebugStringAppender w/ VS2005

I am writing a windows EXE application and trying to use the
OutputDebugStringAppender to get a dump in the output window of VS2005
with no luck.  Here is the app.config:

-------------------------
  <log4net>

    <!-- Define some output appenders -->
    <appender name="RollingLogFileAppender"
type="log4net.Appender.RollingFileAppender">
      <file value="TOCEngine.Rolling.txt" />
      <appendToFile value="true" />
      <maxSizeRollBackups value="10" />
      <maximumFileSize value="1MB" />
      <rollingStyle value="Once" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <header value="[Header]&#13;&#10;" />
        <footer value="[Footer]&#13;&#10;" />
        <conversionPattern value="%date [%thread] %-5level %logger
[%ndc] - %message%newline" />
      </layout>
    </appender>

    <appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date %message%newline" />
      </layout>
    </appender>

    <appender name="DebugConsoleOutput"
type="log4net.Appender.OutputDebugStringAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date %message%newline" />
      </layout>
    </appender>

    <!-- Setup the root category, add the appenders and set the
default level -->
    <root>
      <level value="DEBUG" />
      <appender-ref ref="DebugConsoleOutput" />
      <appender-ref ref="RollingLogFileAppender" />
    </root>

    <!-- Specify the level for some specific categories -->
    <logger name="Nano.TOCEngine.Program">
      <level value="ALL" />
      <appender-ref ref="ConsoleAppender" />
    </logger>
  </log4net>
-------------------------

Any thoughts on how I get it to log to the VS2005 window?

Sam

Dean Fiala | 9 Jun 2006 21:19
Favicon

RE: OutputDebugStringAppender w/ VS2005

This is a little bit of goofiness that is documented somewhere.  You'll find
that the 
log4net.Appender.TraceAppender
Will do what you want.  This is what I use....

     <!-- to show in Debug output use trace instead -->
    <appender name="Debugger" type="log4net.Appender.TraceAppender">
        <layout type="log4net.Layout.SimpleLayout" />
    </appender>

-----Original Message-----
From: scarleton <at> gmail.com [mailto:scarleton <at> gmail.com] On Behalf Of Sam
Carleton
Sent: Friday, June 09, 2006 2:31 PM
To: log4net-user <at> logging.apache.org
Subject: OutputDebugStringAppender w/ VS2005

I am writing a windows EXE application and trying to use the
OutputDebugStringAppender to get a dump in the output window of VS2005 with
no luck.  Here is the app.config:

-------------------------
  <log4net>

    <!-- Define some output appenders -->
    <appender name="RollingLogFileAppender"
type="log4net.Appender.RollingFileAppender">
      <file value="TOCEngine.Rolling.txt" />
      <appendToFile value="true" />
      <maxSizeRollBackups value="10" />
      <maximumFileSize value="1MB" />
      <rollingStyle value="Once" />
      <staticLogFileName value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <header value="[Header]&#13;&#10;" />
        <footer value="[Footer]&#13;&#10;" />
        <conversionPattern value="%date [%thread] %-5level %logger [%ndc] -
%message%newline" />
      </layout>
    </appender>

    <appender name="ConsoleAppender"
type="log4net.Appender.ConsoleAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date %message%newline" />
      </layout>
    </appender>

    <appender name="DebugConsoleOutput"
type="log4net.Appender.OutputDebugStringAppender">
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date %message%newline" />
      </layout>
    </appender>

    <!-- Setup the root category, add the appenders and set the default
level -->
    <root>
      <level value="DEBUG" />
      <appender-ref ref="DebugConsoleOutput" />
      <appender-ref ref="RollingLogFileAppender" />
    </root>

    <!-- Specify the level for some specific categories -->
    <logger name="Nano.TOCEngine.Program">
      <level value="ALL" />
      <appender-ref ref="ConsoleAppender" />
    </logger>
  </log4net>
-------------------------

Any thoughts on how I get it to log to the VS2005 window?

Sam

tinhuty he | 10 Jun 2006 05:44
Picon
Favicon

Re: how to set property for application level

Thanks so much. Exactly what I want.

One more question: I have a windows form application and I want some of the 
log entries automatically appear in some area of form(for example right 
bottom of the form). what is the best way to do it?

Thanks.

= = = Original message = = =

Have you tried the GlobalContext?

--- tinhuty he <tinhuty <at> hotmail.com> wrote:

>How can I set a property in application level so that all logs
>produced from that application will have this property in log file, 
>including all
>logs produced from other assemblies used by this application?
>
>For example I want to all my log has an property "appname" to stored
>the value of application name. I tried to set an application name:
>ThreadContext.Properties["appname"] = "App1";
>This doesn't work as what I wanted. Some of the log entries don't
>have this property.
>
>How should I approach it?
>
>Thanks.

___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/


Gmane