November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
In AssembyInfo.cs (in folder /Properties/) add:
using log4net.Config;
[assembly: XmlConfigurator(ConfigFile = "EPiServerLog.config", Watch = true)]
And here is a good basic setting:
<?xml version="1.0" encoding="utf-8"?>
<log4net>
<!-- Use a new log file for each day -->
<appender name="fileLogAppender" type="log4net.Appender.RollingFileAppender" >
<file value="C:\Logs\Customer\Customer" />
<encoding value="utf-8" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<staticLogFileName value="false" />
<datePattern value=".yyyyMMdd.'log'" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level [%thread] %type.%method - %message%n" />
</layout>
</appender>
<!-- Log everything concerning site business logic (entire namespace) -->
<logger name="MyNameSpace.MyOther">
<level value="DEBUG" />
</logger>
<!-- Log when EPiServer saves a page to the database -->
<logger name="EPiServer.DataAccess.PageSaveDB">
<level value="Off" />
</logger>
<!-- Disable/reduce logging for log-intensive types -->
<logger name="EPiServer.Events.Remote.RemoteEventsManager">
<level value="Error" />
</logger>
<logger name="EPiServer.Web.InitializationModule">
<level value="Error" />
</logger>
<logger name="EPiServer.Framework.Initialization.InitializationEngine">
<level value="Error" />
</logger>
<!-- Levels: Off, Fatal, Error, Warn, Info, Debug, All -->
<root>
<level value="Warn" />
<appender-ref ref="fileLogAppender" />
</root>
</log4net>
Have added the assebly lines in my "AssemblyInfo.cs" of the assembly wich my logging is in, but still no sign of any logging.
Has the level value to "All" on root, and fileLogAppender (default unedited epi filelog appender) on.
There should be good access rights, and in the logging of log4net it self i cannot se any errors at all. I cannot understand why this is not working, so simple yet so hard.
I dont know how the default settings are. But try my example and check the permissions.
This is my current log config.
<?xml version="1.0" encoding="utf-8"?>
<log4net>
<!-- LogAppender used to send log messages to the Log Service
Values:
encoding - has to be set to Unicode
remoteAddress - ip-address for your log service
remotePort - has to be set to the same port as defined in
'udpClientPort' in the configuration file for the log service
located in the file %PROGRAMFILES%/EPiServer.LogService5/EPiServer.Log.Service.exe.config
-->
<appender name="StatisticsUdpAppender" type="EPiServer.Diagnostics.EPiServerUdpAppender, EPiServer">
<remoteAddress value="127.0.0.1" />
<remotePort value="7071" />
</appender>
<appender name="fileLogAppender" type="log4net.Appender.FileAppender" >
<!-- The path is relative to the application base, i.e. the EPiServerSample directory. ASP.NET Machine Account must have modify rights there.
You probably do NOT want to place it in the application base directory, as it is potentially avaialable to Web site vistors.
DO CHANGE THE LOCATION BELOW FOR PRODUCTION SYSTEMS -->
<file value="EPiServerErrorLog.txt" />
<!-- Typical encoding values are Unicode/utf-16 or utf-8 or ascii. See System.Text.Encoding for more info. Omit this tag to get the system default Ansi -->
<!-- Use utf-8 for the file appender to conform to EPiServer practices and reduce log file size -->
<encoding value="utf-8" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<!-- You should be aware that generating type and method information is very SLOW -->
<conversionPattern value="%date %level [%thread] %type.%method - %message%n" />
</layout>
</appender>
<!-- Try the logview4net utility to listen to UDP-logs, download from sourceforge.net -->
<appender name="udpLogAppender" type="log4net.Appender.UdpAppender" >
<!-- Typical encoding values are Unicode/utf-16 or utf-8 or ascii. See System.Text.Encoding for more info. Omit this tag to get the system default Ansi -->
<!-- Use utf-16 since it's default for logvivew4net -->
<encoding value="utf-16" />
<!-- Be careful where you send the logs, they may contain sensitive data. You can use 224.0.0.1 for the local net -->
<remoteAddress value="127.0.0.1" />
<remotePort value="8082" />
<layout type="log4net.Layout.PatternLayout">
<!-- You should be aware that generating type and method information is very SLOW -->
<conversionPattern value="%date %level [%thread] %type.%method - %message%n%exception" />
</layout>
</appender>
<!-- The RollingFileAppender will create new files according to the settings, typically once every day for example -->
<appender name="fileStatisticsAppender" type="log4net.Appender.RollingFileAppender">
<!-- The path is relative to the application base, i.e. the EPiServerSample directory. ASP.NET Machine Account must have modify rights there.
You probably do NOT want to place it in the application base directory, as it is potentially avaialable to Web site vistors.
DO CHANGE THE LOCATION BELOW FOR PRODUCTION SYSTEMS -->
<file value="EPiServerStatisticsLog.txt" />
<!-- Typical encoding values are Unicode/utf-16 or utf-8 or ascii. See System.Text.Encoding for more info. Omit this tag to get the system default Ansi -->
<!-- use ASCII to make it easy for other programs to interpret the contents of the statistics log -->
<encoding value="ascii" />
<lockingModel type="log4net.Appender.RollingFileAppender+MinimalLock" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<layout type="log4net.Layout.PatternLayout">
<!-- You should be aware that generating type and method information is very SLOW -->
<param name="ConversionPattern" value="%date|%message%n" />
</layout>
</appender>
<!-- Statistics are sent to this logger, when enabled -->
<logger name="EPiServer.UI.Util.PixelImg">
<!-- Statistics are sent as 'Info' level logs, set the level to "All" to enable logging, "Off" to disable statistics logging -->
<level value="All" />
<appender-ref ref="StatisticsUdpAppender" />
</logger>
<!-- Reduce amount of logging from OptimisticCache -->
<logger name="EPiServer.Core.OptimisticCache" additivity="false">
<level value="Error" />
</logger>
<!-- Reduce amount of logging from DataAccessBase -->
<logger name="EPiServer.DataAccess.DataAccessBase" additivity="false">
<level value="Error" />
</logger>
<!-- Error and general program flow logs are sent to the root logger. Note that all logs, including statistics if enabled,
will be sent to these appenders as well -->
<root>
<!-- You can use levels, in increasing order of verbosity: Off, Fatal, Error, Warn, Info, Debug, All -->
<level value="All" />
<!--level value="Warn" /-->
<!-- Uncomment one or all of the appender-ref's, or add additional ones -->
<appender-ref ref="fileLogAppender" />
<!-- LogView4net is a good application to use to listen to logging output via UDP. Find it on sourceforge. -->
<!-- appender-ref ref="udpLogAppender" / -->
</root>
</log4net>
Added your example log config as a new file, changed the AssemblyInfo to this one.
Changed from Warn to All.
Changed ouput path to same directory as the internal log4net log is created, so logicly (i think) there should be no problem with permissions.
Still no luck though. Still no errors in log4net interal log and no new log file according to the config.
You can try to use debug output appender and DebugView tool to read logs. In this case you don't depend on any file system and access rights. It's very easy to filter logs and you can see it in real time. Probably you will have to play with options in "Capture" menu to make it show your logs.
Sample configuration for that:
<?xml version="1.0" encoding="utf-8"?>
<log4net>
<!--Appender to write message to debug output-->
<appender name="OutputDebugStringAppender" type="log4net.Appender.OutputDebugStringAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %type.%method - %message%newline" />
</layout>
</appender>
<root>
<level value="Debug" />
<appender-ref ref="OutputDebugStringAppender" />
</root>
</log4net>
I guess you will see errors in DebugView if log4net cannot be initialized. Check also windows event log.
Downloaded and ran DebugView but nothing is logged so i guess the log4net is not doing anything. Or im using the program woring.
Looked in the windows event log but finds nothing related, exept that my sheduled job ran "OK" everytime.
Under what account is the schedular service running? The scheduled job is not running under the same context as the website.
I'm quite sure it's related to the permissions.
Do you configure logging for the site of for the Scheduler service? Try to add logging configuration to Scheduler service config file or in log4net.config in service folder.
The sheduled job plugin code/class is in the same assembly as the main episerver site. And i start the job manually (logged in account in episerver).
Skipped the code in assembly info and added to the config sections:
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
And then to the AppSettings section:
<add key="log4net.Config" value="log4net.config" />
And now it is logging as i want it to, though i never got any results in the DebugViewer but it loggs to file as intended.
Do not add the log4net attribute to assemblyinfo, this is already in place in episerver.dll (is it in the bin directory?) You do not have to add logging settings to web.config, it should all be taken care of for you by the XmlConfigurator attribute in EPiServer.dll. Something else is wrong if it is still not logging.
Make sure you're not affected by this: http://world.episerver.com/Blogs/Steve-Celius/Dates/2010/4/log4net-Tips-Do-not-declare-a-logger-in-Globalasaxcs/
We have never used the log4net before in the project so we have not declared any in any global.asax.
The only thing that made the project log anything was adding the log4net section to web.config and define log4net.Config as app setting, and then epi itself started logging when i had it on, epi never logged anything before either. But since it works now i intend to run with the setup.
Have browsed the epiforum on this and also googled other sources for configuring this.
We are running CMS 6 R2.
I have the standard log.config from episerver. Set <root> section to log level "All", and decommented the default file appender.
I have my class for example purporse "foo.bar.myClass" in namespace "foo.bar".
Since nothing is working i have enabled the logging of the log4Net it self.
http://labs.dropit.se/blogs/post/2009/10/14/How-to-log-log4net.aspx
And that is the only thing logging anything so far. I have checked on the logging files and cant se any errors so far.
Small sample of what is in the log4net loggings.