Log File Creation Problem

Jun 10, 2014 at 1:13 PM
Hi All,
In My project , am using Enterprise library 3.0 for logging. Whenever error is happened, its creating a new log file( WITH GUID). I dont want to create a log file everey time . Need to append a content in the file if file exist otherwise create a new one.
Thanks & regards,
Dileep Sanker
Jun 11, 2014 at 2:23 AM
This is caused by file locking when multiple trace listeners attempt to write to the same file. Can you expand on the scenario with code and configuration?

If you are using the Exception Handling Block try setting the UseDefaultLogger property of the LoggingHandler to true as per this FAQ.

~~
Randy Levy
entlib.support@live.com
Enterprise Library support engineer
Support How-to
Jun 11, 2014 at 6:32 AM
Hi,
This is my webconfig File and its not resoved yet. pls help and guide me,
<loggingConfiguration name="Logging Application Block" tracingEnabled="true" defaultCategory="" logWarningsWhenNoCategoriesMatch="true">
    <listeners>
        <add fileName="//PROD/AISWebLogs/aisshare/LogFiles/Prod.log" header="----------------------------------------" footer="----------------------------------------" formatter="Text Formatter" listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.FlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" traceOutputOptions="Callstack" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.FlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" name="FlatFile TraceListener"/>
    </listeners>
    <formatters>
        <add template="Timestamp: {local}&#xA;Message: {message}&#xA;Category: {category}&#xA;Priority: {priority}&#xA;EventId: {eventid}&#xA;Severity: {severity}&#xA;Title:{title}&#xA;Machine: {machine}&#xA;Application Domain: {appDomain}&#xA;Process Id: {processId}&#xA;Process Name: {processName}&#xA;Win32 Thread Id: {win32ThreadId}&#xA;Thread Name: {threadName}&#xA;Extended Properties: {dictionary({key} - {value}&#xA;)}" type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.TextFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" name="Text Formatter"/>
    </formatters>
    <logFilters>
        <add categoryFilterMode="AllowAllExceptDenied" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.CategoryFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" name="Category"/>
        <add minimumPriority="0" maximumPriority="2147483647" type="Microsoft.Practices.EnterpriseLibrary.Logging.Filters.PriorityFilter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" name="Priority Filter"/>
    </logFilters>
    <categorySources>
        <add switchValue="All" name="Default Category">
            <listeners>
                <add name="FlatFile 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="FlatFile TraceListener"/>
            </listeners>
        </errors>
    </specialSources>
</loggingConfiguration>