Logging Application Block Not Writing to Vista Event Log

Discussion in 'ASP .Net' started by coconet, Feb 6, 2008.

  1. coconet

    coconet Guest

    Running Vista x64. Visual Studio 2008 Web Application Project.

    I installed Enterprise Library 3.1, built it, and modified the
    web.config. I want to log everything to a text file, and log
    everything that is a Warning or more severe to the Application Event
    Log.

    Everything properly logs to the file, but nothing is in the Event Log.

    Why?

    My C# Code:

    LogEntry logEntry = new LogEntry();
    logEntry.EventId = 100;
    logEntry.Categories.Add( "TestCategory" );
    logEntry.Priority = 1;
    logEntry.Severity = TraceEventType.Error;
    logEntry.Message = "qwerty";
    logEntry.Title = "asdfgh";
    logEntry.MachineName = Environment.MachineName;
    Logger.Write( logEntry );


    In my web.config:

    <loggingConfiguration name="Logging Application Block"
    tracingEnabled="true" defaultCategory=""
    logWarningsWhenNoCategoriesMatch="true">
    <listeners>
    <add
    fileName="c:\trace.log"
    header="----------------------------------------"
    footer="----------------------------------------"
    formatter="Text Formatter"

    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData,
    Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    traceOutputOptions="None"
    type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener,
    Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    name="FlatFile TraceListener"
    />
    <add
    source="Source00001"
    formatter="Text Formatter"
    log="Application"
    machineName=""

    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FormattedEventLogTraceListenerData,
    Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    traceOutputOptions="None"

    type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FormattedEventLogTraceListener,
    Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    name="Formatted EventLog TraceListener"
    />
    </listeners>
    <formatters>
    <add
    template="Timestamp: {timestamp}
    Message:
    {message}
    Category: {category}
    Priority:
    {priority}
    EventId: {eventid}
    Severity:
    {severity}
    Title:{title}
    Machine:
    {machine}
    Application Domain: {appDomain}
    Process
    Id: {processId}
    Process Name: {processName}
    Win32
    Thread Id: {win32ThreadId}
    Thread Name:
    {threadName}
    Extended Properties: {dictionary({key} -
    {value}
    )}"

    type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter,
    Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    name="Text Formatter"
    />
    </formatters>
    <specialSources>
    <allEvents
    switchValue="All"
    name="All Events">
    <listeners>
    <add
    name="FlatFile TraceListener"
    />
    </listeners>
    </allEvents>
    <notProcessed
    switchValue="All"
    name="Unprocessed Category"
    />
    <errors
    switchValue="Error"
    name="Logging Errors &amp; Warnings">
    <listeners>
    <add
    name="Formatted EventLog TraceListener"
    />
    </listeners>
    </errors>
    </specialSources>
    </loggingConfiguration>
    coconet, Feb 6, 2008
    #1
    1. Advertising

  2. Hi ,

    From your description, you're encountering some problem to use Logging
    Application Block to write entry into eventlog on a Vista x64 box ,correct?

    Since you're developing an ASP.NET web applicaiton, are you using the VS
    IDE's built-in test server or host the application in IIS? I suggest you
    try the following things first:

    ** change the listenter setting and also let EventLogListener to log all
    the messages(not only high severity ones)

    ** in your ASP.NET application, use normal .NET EventLog API to log into
    the same EventSource to see whether it works.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    This posting is provided "AS IS" with no warranties, and confers no rights.





    --------------------
    >From: coconet <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >Subject: Logging Application Block Not Writing to Vista Event Log
    >Date: Wed, 06 Feb 2008 13:59:17 -0500


    >
    >
    >Running Vista x64. Visual Studio 2008 Web Application Project.
    >
    >I installed Enterprise Library 3.1, built it, and modified the
    >web.config. I want to log everything to a text file, and log
    >everything that is a Warning or more severe to the Application Event
    >Log.
    >
    >Everything properly logs to the file, but nothing is in the Event Log.
    >
    >Why?
    >
    >My C# Code:
    >
    >LogEntry logEntry = new LogEntry();
    >logEntry.EventId = 100;
    >logEntry.Categories.Add( "TestCategory" );
    >logEntry.Priority = 1;
    >logEntry.Severity = TraceEventType.Error;
    >logEntry.Message = "qwerty";
    >logEntry.Title = "asdfgh";
    >logEntry.MachineName = Environment.MachineName;
    >Logger.Write( logEntry );
    >
    >
    >In my web.config:
    >
    ><loggingConfiguration name="Logging Application Block"
    >tracingEnabled="true" defaultCategory=""
    >logWarningsWhenNoCategoriesMatch="true">
    ><listeners>
    ><add
    > fileName="c:\trace.log"
    > header="----------------------------------------"
    > footer="----------------------------------------"
    > formatter="Text Formatter"
    >
    >listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configurati

    on.FlatFileTraceListenerData,
    >Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    >Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    > traceOutputOptions="None"
    >type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFile

    TraceListener,
    >Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    >Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    > name="FlatFile TraceListener"
    >/>
    ><add
    > source="Source00001"
    > formatter="Text Formatter"
    > log="Application"
    > machineName=""
    >
    >listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configurati

    on.FormattedEventLogTraceListenerData,
    >Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    >Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    > traceOutputOptions="None"
    >
    >type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.Formatte

    dEventLogTraceListener,
    >Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    >Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    > name="Formatted EventLog TraceListener"
    >/>
    ></listeners>
    ><formatters>
    ><add
    > template="Timestamp: {timestamp}
    Message:
    >{message}
    Category: {category}
    Priority:
    >{priority}
    EventId: {eventid}
    Severity:
    >{severity}
    Title:{title}
    Machine:
    >{machine}
    Application Domain: {appDomain}
    Process
    >Id: {processId}
    Process Name: {processName}
    Win32
    >Thread Id: {win32ThreadId}
    Thread Name:
    >{threadName}
    Extended Properties: {dictionary({key} -
    >{value}
    )}"
    >
    >type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatte

    r,
    >Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    >Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    > name="Text Formatter"
    >/>
    ></formatters>
    ><specialSources>
    ><allEvents
    > switchValue="All"
    > name="All Events">
    ><listeners>
    ><add
    > name="FlatFile TraceListener"
    >/>
    ></listeners>
    ></allEvents>
    ><notProcessed
    > switchValue="All"
    > name="Unprocessed Category"
    >/>
    ><errors
    > switchValue="Error"
    > name="Logging Errors &amp; Warnings">
    ><listeners>
    ><add
    > name="Formatted EventLog TraceListener"
    >/>
    ></listeners>
    ></errors>
    ></specialSources>
    ></loggingConfiguration>
    >
    >
    >
    >
    >
    Steven Cheng[MSFT], Feb 7, 2008
    #2
    1. Advertising

  3. coconet

    coconet Guest

    Please provide sample C# code or web.config text so I can test,
    thanks.


    On Thu, 07 Feb 2008 04:09:04 GMT, (Steven
    Cheng[MSFT]) wrote:

    >
    >Hi ,
    >
    >From your description, you're encountering some problem to use Logging
    >Application Block to write entry into eventlog on a Vista x64 box ,correct?
    >
    >Since you're developing an ASP.NET web applicaiton, are you using the VS
    >IDE's built-in test server or host the application in IIS? I suggest you
    >try the following things first:
    >
    >** change the listenter setting and also let EventLogListener to log all
    >the messages(not only high severity ones)
    >
    >** in your ASP.NET application, use normal .NET EventLog API to log into
    >the same EventSource to see whether it works.
    >
    >Sincerely,
    >
    >Steven Cheng
    >
    >Microsoft MSDN Online Support Lead
    >
    >
    >
    >This posting is provided "AS IS" with no warranties, and confers no rights.
    >
    >
    >
    >
    >
    >--------------------
    >>From: coconet <>
    >>Newsgroups: microsoft.public.dotnet.framework.aspnet
    >>Subject: Logging Application Block Not Writing to Vista Event Log
    >>Date: Wed, 06 Feb 2008 13:59:17 -0500

    >
    >>
    >>
    >>Running Vista x64. Visual Studio 2008 Web Application Project.
    >>
    >>I installed Enterprise Library 3.1, built it, and modified the
    >>web.config. I want to log everything to a text file, and log
    >>everything that is a Warning or more severe to the Application Event
    >>Log.
    >>
    >>Everything properly logs to the file, but nothing is in the Event Log.
    >>
    >>Why?
    >>
    >>My C# Code:
    >>
    >>LogEntry logEntry = new LogEntry();
    >>logEntry.EventId = 100;
    >>logEntry.Categories.Add( "TestCategory" );
    >>logEntry.Priority = 1;
    >>logEntry.Severity = TraceEventType.Error;
    >>logEntry.Message = "qwerty";
    >>logEntry.Title = "asdfgh";
    >>logEntry.MachineName = Environment.MachineName;
    >>Logger.Write( logEntry );
    >>
    >>
    >>In my web.config:
    >>
    >><loggingConfiguration name="Logging Application Block"
    >>tracingEnabled="true" defaultCategory=""
    >>logWarningsWhenNoCategoriesMatch="true">
    >><listeners>
    >><add
    >> fileName="c:\trace.log"
    >> header="----------------------------------------"
    >> footer="----------------------------------------"
    >> formatter="Text Formatter"
    >>
    >>listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configurati

    >on.FlatFileTraceListenerData,
    >>Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    >>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    >> traceOutputOptions="None"
    >>type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFile

    >TraceListener,
    >>Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    >>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    >> name="FlatFile TraceListener"
    >>/>
    >><add
    >> source="Source00001"
    >> formatter="Text Formatter"
    >> log="Application"
    >> machineName=""
    >>
    >>listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configurati

    >on.FormattedEventLogTraceListenerData,
    >>Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    >>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    >> traceOutputOptions="None"
    >>
    >>type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.Formatte

    >dEventLogTraceListener,
    >>Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    >>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    >> name="Formatted EventLog TraceListener"
    >>/>
    >></listeners>
    >><formatters>
    >><add
    >> template="Timestamp: {timestamp}
    Message:
    >>{message}
    Category: {category}
    Priority:
    >>{priority}
    EventId: {eventid}
    Severity:
    >>{severity}
    Title:{title}
    Machine:
    >>{machine}
    Application Domain: {appDomain}
    Process
    >>Id: {processId}
    Process Name: {processName}
    Win32
    >>Thread Id: {win32ThreadId}
    Thread Name:
    >>{threadName}
    Extended Properties: {dictionary({key} -
    >>{value}
    )}"
    >>
    >>type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatte

    >r,
    >>Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    >>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    >> name="Text Formatter"
    >>/>
    >></formatters>
    >><specialSources>
    >><allEvents
    >> switchValue="All"
    >> name="All Events">
    >><listeners>
    >><add
    >> name="FlatFile TraceListener"
    >>/>
    >></listeners>
    >></allEvents>
    >><notProcessed
    >> switchValue="All"
    >> name="Unprocessed Category"
    >>/>
    >><errors
    >> switchValue="Error"
    >> name="Logging Errors &amp; Warnings">
    >><listeners>
    >><add
    >> name="Formatted EventLog TraceListener"
    >>/>
    >></listeners>
    >></errors>
    >></specialSources>
    >></loggingConfiguration>
    >>
    >>
    >>
    >>
    >>
    coconet, Feb 7, 2008
    #3
  4. Thanks for your reply Coconet,

    The code to manually write an EventLog entry is quite simple, here is a
    function doing it:

    ========================
    private void btnWriteEventLog_Click(object sender, EventArgs e)
    {
    string source = "my App EventSource";
    string log = "Application";
    string message = "require more gas!";

    if (!EventLog.SourceExists(source))
    {
    EventLog.CreateEventSource(source, log);
    }

    EventLog.WriteEntry(source, message);
    }
    ===================

    it include two parts:

    * first check whether the eventSource exists, if not, create it

    ** write message into the eventSource

    Based on my experience, there is a typical permission issue that ASP.NET
    worker process acount may not have permission to create EventSource, but
    can write into an existing eventsource. Therefore, you can try checking
    whether you can get this code work or if your original problem is due to
    the eventsource is not correctly created.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.

    --------------------
    >From: coconet <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >Subject: Re: Logging Application Block Not Writing to Vista Event Log
    >Date: Thu, 07 Feb 2008 10:24:05 -0500


    >
    >Please provide sample C# code or web.config text so I can test,
    >thanks.
    >
    >
    >On Thu, 07 Feb 2008 04:09:04 GMT, (Steven
    >Cheng[MSFT]) wrote:
    >
    >>
    >>Hi ,
    >>
    >>From your description, you're encountering some problem to use Logging
    >>Application Block to write entry into eventlog on a Vista x64 box

    ,correct?
    >>
    >>Since you're developing an ASP.NET web applicaiton, are you using the VS
    >>IDE's built-in test server or host the application in IIS? I suggest you
    >>try the following things first:
    >>
    >>** change the listenter setting and also let EventLogListener to log all
    >>the messages(not only high severity ones)
    >>
    >>** in your ASP.NET application, use normal .NET EventLog API to log into
    >>the same EventSource to see whether it works.
    >>
    >>Sincerely,
    >>
    >>Steven Cheng
    >>
    >>Microsoft MSDN Online Support Lead
    >>
    >>
    >>
    >>This posting is provided "AS IS" with no warranties, and confers no

    rights.
    >>
    >>
    >>
    >>
    >>
    >>--------------------
    >>>From: coconet <>
    >>>Newsgroups: microsoft.public.dotnet.framework.aspnet
    >>>Subject: Logging Application Block Not Writing to Vista Event Log
    >>>Date: Wed, 06 Feb 2008 13:59:17 -0500

    >>
    >>>
    >>>
    >>>Running Vista x64. Visual Studio 2008 Web Application Project.
    >>>
    >>>I installed Enterprise Library 3.1, built it, and modified the
    >>>web.config. I want to log everything to a text file, and log
    >>>everything that is a Warning or more severe to the Application Event
    >>>Log.
    >>>
    >>>Everything properly logs to the file, but nothing is in the Event Log.
    >>>
    >>>Why?
    >>>
    >>>My C# Code:
    >>>
    >>>LogEntry logEntry = new LogEntry();
    >>>logEntry.EventId = 100;
    >>>logEntry.Categories.Add( "TestCategory" );
    >>>logEntry.Priority = 1;
    >>>logEntry.Severity = TraceEventType.Error;
    >>>logEntry.Message = "qwerty";
    >>>logEntry.Title = "asdfgh";
    >>>logEntry.MachineName = Environment.MachineName;
    >>>Logger.Write( logEntry );
    >>>
    >>>
    >>>In my web.config:
    >>>
    >>><loggingConfiguration name="Logging Application Block"
    >>>tracingEnabled="true" defaultCategory=""
    >>>logWarningsWhenNoCategoriesMatch="true">
    >>><listeners>
    >>><add
    >>> fileName="c:\trace.log"
    >>> header="----------------------------------------"
    >>> footer="----------------------------------------"
    >>> formatter="Text Formatter"
    >>>
    >>>listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configura

    ti
    >>on.FlatFileTraceListenerData,
    >>>Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    >>>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    >>> traceOutputOptions="None"
    >>>type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFi

    le
    >>TraceListener,
    >>>Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    >>>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    >>> name="FlatFile TraceListener"
    >>>/>
    >>><add
    >>> source="Source00001"
    >>> formatter="Text Formatter"
    >>> log="Application"
    >>> machineName=""
    >>>
    >>>listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configura

    ti
    >>on.FormattedEventLogTraceListenerData,
    >>>Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    >>>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    >>> traceOutputOptions="None"
    >>>
    >>>type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.Format

    te
    >>dEventLogTraceListener,
    >>>Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    >>>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    >>> name="Formatted EventLog TraceListener"
    >>>/>
    >>></listeners>
    >>><formatters>
    >>><add
    >>> template="Timestamp: {timestamp}
    Message:
    >>>{message}
    Category: {category}
    Priority:
    >>>{priority}
    EventId: {eventid}
    Severity:
    >>>{severity}
    Title:{title}
    Machine:
    >>>{machine}
    Application Domain: {appDomain}
    Process
    >>>Id: {processId}
    Process Name: {processName}
    Win32
    >>>Thread Id: {win32ThreadId}
    Thread Name:
    >>>{threadName}
    Extended Properties: {dictionary({key} -
    >>>{value}
    )}"
    >>>
    >>>type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormat

    te
    >>r,
    >>>Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    >>>Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    >>> name="Text Formatter"
    >>>/>
    >>></formatters>
    >>><specialSources>
    >>><allEvents
    >>> switchValue="All"
    >>> name="All Events">
    >>><listeners>
    >>><add
    >>> name="FlatFile TraceListener"
    >>>/>
    >>></listeners>
    >>></allEvents>
    >>><notProcessed
    >>> switchValue="All"
    >>> name="Unprocessed Category"
    >>>/>
    >>><errors
    >>> switchValue="Error"
    >>> name="Logging Errors &amp; Warnings">
    >>><listeners>
    >>><add
    >>> name="Formatted EventLog TraceListener"
    >>>/>
    >>></listeners>
    >>></errors>
    >>></specialSources>
    >>></loggingConfiguration>
    >>>
    >>>
    >>>
    >>>
    >>>

    >
    >
    Steven Cheng[MSFT], Feb 8, 2008
    #4
  5. coconet

    coconet Guest

    That does not show me how to do it with the Logging Application Block.
    I know how to manually log with code. I need to see a simple web
    application project's web.config file and .cs file showing how to
    write errors-only to the application event log while writing all
    information (debug/trace/error) to a local text file.

    Please try again.

    Thanks.


    On Fri, 08 Feb 2008 06:52:07 GMT, (Steven
    Cheng[MSFT]) wrote:

    >Thanks for your reply Coconet,
    >
    >The code to manually write an EventLog entry is quite simple, here is a
    >function doing it:
    >
    >========================
    >private void btnWriteEventLog_Click(object sender, EventArgs e)
    > {
    > string source = "my App EventSource";
    > string log = "Application";
    > string message = "require more gas!";
    >
    > if (!EventLog.SourceExists(source))
    > {
    > EventLog.CreateEventSource(source, log);
    > }
    >
    > EventLog.WriteEntry(source, message);
    >}
    >===================
    >
    coconet, Feb 11, 2008
    #5
  6. Thanks for your reply,

    The Enterprise Library Logging block code is also straightforward, my test
    just used a single EventLog Listener and write a message into the test
    event source. On Vista box, it execute under an application run with
    Elevated privilege and it works well.


    ======code=======
    private void button1_Click(object sender, EventArgs e)
    {
    LogEntry entry = new LogEntry();
    entry.EventId = 1;
    entry.Priority = 1;
    entry.Message = "This is a test message.";
    entry.Categories.Clear();
    entry.Categories.Add("General");
    Logger.Write(entry);
    MessageBox.Show("Log is written");
    }
    =====================

    =========config ==========
    <?xml version="1.0" encoding="utf-8"?>
    <configuration>
    <configSections>
    <section name="loggingConfiguration"
    type="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.LoggingSet
    tings, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    <section name="dataConfiguration"
    type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSetti
    ngs, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </configSections>
    <loggingConfiguration name="Logging Application Block"
    tracingEnabled="true"
    defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
    <add source="Enterprise Library Logging" formatter="Text
    Formatter"
    log="Application" machineName=""
    listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuratio
    n.FormattedEventLogTraceListenerData,
    Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    traceOutputOptions="None"
    type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.Formatted
    EventLogTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging,
    Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    name="Formatted EventLog TraceListener" />
    </listeners>
    <formatters>
    <add template="Timestamp: {timestamp}
    Message:
    {message}
    Category: {category}
    Priority:
    {priority}
    EventId: {eventid}
    Severity:
    {severity}
    Title:{title}
    Machine:
    {machine}
    Application Domain: {appDomain}
    Process Id:
    {processId}
    Process Name: {processName}
    Win32 Thread Id:
    {win32ThreadId}
    Thread Name: {threadName}
    Extended
    Properties: {dictionary({key} - {value}
    )}"

    type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter
    , Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.1.0.0,
    Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
    name="Text Formatter" />
    </formatters>
    <categorySources>
    <add switchValue="All" name="General">
    <listeners>
    <add name="Formatted EventLog TraceListener" />
    </listeners>
    </add>
    </categorySources>
    <specialSources>
    <allEvents switchValue="All" name="All Events" />
    <notProcessed switchValue="All" name="Unprocessed Category" />
    <errors switchValue="All" name="Logging Errors &amp; Warnings">
    <listeners>
    <add name="Formatted EventLog TraceListener" />
    </listeners>
    </errors>
    </specialSources>
    </loggingConfiguration>
    </configuration>
    ===========================

    Performing the same test and compare with your original case may help
    verify whether the problem is specific to the application context(security,
    application mode -- web or desktop ...).

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.

    --------------------
    >From: coconet <>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet
    >Subject: Re: Logging Application Block Not Writing to Vista Event Log
    >Date: Mon, 11 Feb 2008 13:40:13 -0500


    >Path:

    TK2MSFTNGHUB02.phx.gbl!TK2MSFTNGP01.phx.gbl!TK2MSFTFEEDS02.phx.gbl!newsfeed0
    0.sul.t-online.de!t-online.de!border2.nntp.dca.giganews.com!border1.nntp.dca
    .giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!news.giganews.
    com.POSTED!not-for-mail
    >Xref: TK2MSFTNGHUB02.phx.gbl microsoft.public.dotnet.framework.aspnet:58839
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >
    >
    >That does not show me how to do it with the Logging Application Block.
    >I know how to manually log with code. I need to see a simple web
    >application project's web.config file and .cs file showing how to
    >write errors-only to the application event log while writing all
    >information (debug/trace/error) to a local text file.
    >
    >Please try again.
    >
    >Thanks.
    >
    >
    >On Fri, 08 Feb 2008 06:52:07 GMT, (Steven
    >Cheng[MSFT]) wrote:
    >
    >>Thanks for your reply Coconet,
    >>
    >>The code to manually write an EventLog entry is quite simple, here is a
    >>function doing it:
    >>
    >>========================
    >>private void btnWriteEventLog_Click(object sender, EventArgs e)
    >> {
    >> string source = "my App EventSource";
    >> string log = "Application";
    >> string message = "require more gas!";
    >>
    >> if (!EventLog.SourceExists(source))
    >> {
    >> EventLog.CreateEventSource(source, log);
    >> }
    >>
    >> EventLog.WriteEntry(source, message);
    >>}
    >>===================
    >>

    >
    Steven Cheng[MSFT], Feb 12, 2008
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Samy
    Replies:
    0
    Views:
    489
  2. =?Utf-8?B?VG9tIFdpbmdlcnQ=?=

    My.Log.Writeexception not writing to Application Event Log.

    =?Utf-8?B?VG9tIFdpbmdlcnQ=?=, Jan 20, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    2,352
    =?Utf-8?B?VG9tIFdpbmdlcnQ=?=
    Jan 20, 2006
  3. =?Utf-8?B?SmVmZkRvdE5ldA==?=

    Writing to a registered source in the Application event log with I

    =?Utf-8?B?SmVmZkRvdE5ldA==?=, Jul 12, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    6,265
    =?Utf-8?B?SmVmZkRvdE5ldA==?=
    Aug 1, 2006
  4. Royan
    Replies:
    1
    Views:
    1,409
    Andrea Francia
    Apr 1, 2008
  5. Tom Wingert
    Replies:
    0
    Views:
    318
    Tom Wingert
    Jan 12, 2006
Loading...

Share This Page