Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 465533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:23:13+00:00 2026-05-12T23:23:13+00:00

I am writing some logs to the event log using the Microsoft enterprise library

  • 0

I am writing some logs to the event log using the Microsoft enterprise library

Its writes logs away fine but doesnt seem to set the category in the event log. The category appears okay in the message body of the log (if I choose to set that) but the event viewer doesnt pick up the category.

What am i missing?


c# source

LogEntry log = new LogEntry();
log.Message = "Test";
log.Categories.Add("Event");
Logger.Write(log);

web config

<loggingConfiguration name="Logging Application Block" tracingEnabled="true"
defaultCategory="General" logWarningsWhenNoCategoriesMatch="true">
<listeners>
  <add source="TestLogSource" formatter="Text Formatter" log="TestLog"
    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}&#xD;&#xA;Message: {message}&#xD;&#xA;Category: {category}&#xD;&#xA;Severity: {severity}"
    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="Events">
    <listeners>
      <add name="Formatted EventLog TraceListener" />
    </listeners>
  </add>
  <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>

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T23:23:14+00:00Added an answer on May 12, 2026 at 11:23 pm

    The EventLog Category is separate and distinct from the LogEntry categories. So I don’t think you can use the LogEntry categories to display in the EventLog category field.

    From a data perspective the types are incompatible: the EventLog category is a short while the LogEntry categories are a string. Yes, in the event viewer it shows a string but this value is looked up via a CategoryMessageFile defined in the registry.

    If you want to be able to do some filtering in the event viewer, you could use the LogEntry.EventId property. You can populate this using any convention you wish. e.g. unique Event IDs for every logging point, an Event ID per layer, an Event ID per class or some other convention.

    As a fallback you can always do a Find for your category within the description of the EventLog Entry.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing some data acquisition software and need a gui plotting library that is
I'm writing some DB routines and I'm using prepared statements. My environment is PDO
Writing some test scripts in IronPython, I want to verify whether a window is
I was writing some ASP.NET control when I came to the scenario where I
I'm writing some documentation in Markdown, and creating a separate file for each section
I am writing some code to determine whether a network domain is registered. For
So I was writing some code today that basically looks like this: string returnString
Say I'm writing some ruby code and I want to use the standard Date
I'm writing some semi-portable code and want to be able to detect when I'm
I was writing some Unit tests last week for a piece of code that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.