Problem with Logging.

Vote:
 

Hi ,

I've created a log4net appender which stores all the information (level set to 'ALL') by following this link https://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/75/Logging/logging-with-log4net/ . I want to write the log to another text file in my local drive. Can someone tell me the process to do that?

Thanks in advance.

#181053
Aug 07, 2017 19:20
Vote:
 

Hi,

I'd look at some log4net troubleshooting to see why log4net isn't logging.

Phil Haack has an old, but still valid blog post at http://haacked.com/archive/2006/09/27/Log4Net_Troubleshooting.aspx/

The TL;DR:

First, enable internal log4net debugging: Add the following to your appSettings in web.config:

<add key="log4net.Internal.Debug" value="true"/>

Then, enable system diagnostics trace. Add  the following to your web.config:

<system.diagnostics>
<trace autoflush="true">
<listeners>
<add name="textWriterTraceListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="C:\tmp\log4net.txt" />
</listeners>
</trace>
</system.diagnostics>

Just remember to change the path in the "initializeData" attribute.

#181056
Edited, Aug 08, 2017 1:10
Vote:
 

Hi Øyvind,

I'm getting the logs in different text file. A part of the log file looks like :

log4net: log4net assembly [log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a]. Loaded from [C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\00e711be\c619242d\assembly\dl3\b3ea354d\122134c0_3d3fd201\log4net.dll]. (.NET Runtime [4.0.30319.42000] on Microsoft Windows NT 6.1.7601 Service Pack 1)
 [log4net.Repository.Hierarchy.Hierarchy]
log4net: Creating repository [log4net-default-repository] using type [log4net.Repository.Hierarchy.Hierarchy]
log4net: configuring repository [log4net-default-repository] using stream
log4net: loading XML configuration
log4net: Converter [message] Option [] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Converter [newline] Option [] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Setting Property [ConversionPattern] to String value [%date [%thread] %level %logger: %message%n]
log4net: Converter [literal] Option [ ] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Converter [logger] Option [] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Converter [literal] Option [: ] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Converter [message] Option [] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Converter [n] Option [] Format [min=-1,max=2147483647,leftAlign=False]
log4net: Setting Property [Layout] to object [log4net.Layout.PatternLayout]
log4net: Type = [0], r0 = [.19700101.log], r1 = [.19700101.log]
log4net: Type = [1], r0 = [.19700101.log], r1 = [.19700101.log]
log4net: Type = [2], r0 = [.19700101.log], r1 = [.19700101.log]
log4net: Type = [3], r0 = [.19700101.log], r1 = [.19700102.log]
log4net: Searched for existing files in [E:\Aspire.InspireDigital.App\Aspire.InspireDigital.App\App_Data]
log4net: curSizeRollBackups starts at [0]
log4net: [.20170808.log] vs. [.20170808.log]
log4net: Opening file for writing [E:\Aspire.InspireDigital.App\Aspire.InspireDigital.App\App_Data\EPiServerErrors.log] append [True]
log4net: Created Appender [errorFileLogAppender]

I tried changing the content in CMS mode(On page edit mode) and i got an render exception, but that is not logged in the file.Can On page edit errors be logged? If so how can i  log them into the file?

#181075
Aug 08, 2017 10:26
Vote:
 

I should get the log in the following format : 2017-08-08 16:33:26,034 [9] INFO LogFile: Log created now ! . What is the content that i'm getting in the above link ? 

#181085
Aug 08, 2017 14:03
Vote:
 

For rendering exception, check out if you have a custom content area renderer. I seem to recall there is one in Alloy demo project and that one also has a try catch that swallows exceptions without logging them. I usually add a line to log those rendering exceptions there.  

#181092
Aug 08, 2017 16:26
Vote:
 

Hi Daniel, actually I got the rendering exception to be logged in the format I  wanted it. What I need to know is how can I get the log details of the CMS errors or CMS changes. For any changes in page or blocks we can use ChangeLog in Admin mode. But for my project I need to record the Episerver CMS login details , admin mode errors if any(like accidental change of some values which cause the project to load) . I want these details to be recorded into a text file. Please suggest any method if you know. 

Thanks in advance.

#181093
Aug 08, 2017 16:46
Vote:
 

This nice and useful info for me. Thanks a lot  

#181791
Edited, Aug 30, 2017 8:27
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.