3

I created an event system that uses Tridion.Logging DLL to write log statements. Following is a sample log statement from the event system code.

Logger.Write("[EventsUtilities.ComponentSave]: ", "Starting page creator ", 
             LoggingCategory.General, System.Diagnostics.TraceEventType.Verbose);

The problem is I am not able to find out where this gets logged. My Tridion.ContentManager.log files does not even get generated.

3

You're not actually supposed to use Tridion.Logging in your implementation code - partially due to the whole configuration hassle, partially because that particular class is not designed for other uses than internal Tridion.

My recommendation? Use log4net.

2

First of all - are ure sure, that your event system code is hit? (try to write the same text with streamwriter to check).

Secondly - for using Tridion.Logging you need specify logging configuration...examples of configuration you can find in web.cfg or tcmSereviceHost.exe.cfg (section - loggingConfiguration). For your situation you must have something like this:

<loggingConfiguration name="Logging Application Block" defaultCategory="General" logWarningsWhenNoCategoriesMatch="false">
<listeners>
  <add name="Trace File" fileName="C:\Path...\YourFileName.log" formatter="Log Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=349a39f202fa9b53" traceOutputOptions="None" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=349a39f202fa9b53" />
</listeners>
<formatters>
  <add name="Log Text Formatter" template="{timestamp} &lt;{win32ThreadId}&gt; {message}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=349a39f202fa9b53" />
</formatters>
<categorySources>
  <add switchValue="All" name="Tridion.Logging.LoggingCategory.Tracing">
    <listeners>
      <add name="Trace File" />
    </listeners>
  </add>
</categorySources>
<specialSources>
  <allEvents switchValue="Information" name="All Events">
    <listeners>
      <add name="Tridion Event Log" />
    </listeners>
  </allEvents>
  <notProcessed switchValue="All" name="Unprocessed Category" />
  <errors switchValue="All" name="Logging Errors &amp; Warnings" />
</specialSources>

BTW - I am not sure, that you need this, and that this a good practice. Tridion.Logging is used mostly in Tridion Core features, such as services (Batch, TcmServiceHost, Publisher, etc.) and you can specify different logging configuration and different listeners for logging. In your example I think easier just to use some StreamWriter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.