This is the code which I use to create a rolling file appender.
public static RollingFileAppender GetRollingFileAppender(string
pFilename, Level pLevel, string pPattern) {
RollingFileAppender fileAppender = new
RollingFileAppender();
fileAppender.File = pFilename;
if (!string.IsNullOrEmpty(pPattern)) {
GetPatternLayout(pPattern);
}
else {
fileAppender.Layout = new SimpleLayout();
}
fileAppender.ImmediateFlush = true;
fileAppender.RollingStyle =
RollingFileAppender.RollingMode.Size;
fileAppender.MaximumFileSize = "10MB";
fileAppender.AppendToFile = true; // default
to append mode
fileAppender.MaxSizeRollBackups = 4;
if (pLevel != null) {
fileAppender.Threshold = pLevel;
}
fileAppender.ActivateOptions();
return fileAppender;
}
public static PatternLayout GetPatternLayout(string pPattern) {
PatternLayout patternLayout = new PatternLayout(pPattern);
patternLayout.ActivateOptions();
return patternLayout;
}
________________________________
From: Pavel Bazanov [mailto:[EMAIL PROTECTED]
Sent: Monday, October 27, 2008 3:17 AM
To: [email protected]
Subject: Help me with dinamically setting up the RollingFileAppender
please
Hello,
I have just downloaded the log4net and I can't use the
RollingFileAppender. Check my code please:
// ###################################################################
var appender = new log4net.Appender.RollingFileAppender();
appender.AppendToFile = true;
appender.File = "log.txt";
appender.MaxFileSize = 10000;
appender.MaxSizeRollBackups = 10;
appender.RollingStyle =
log4net.Appender.RollingFileAppender.RollingMode.Size;
log4net.Config.BasicConfigurator.Configure(appender);
log.Info("event occurred");
// ###################################################################
No errors produced, but no log file is created, it just looks like
nothing happens.
What am I doing wrong?
Thank you in advance.
==========================================
NOTICE: The contents of this e-mail message and any attachments are intended
solely for the addressee(s) named in this message. This communication is
intended to be and to remain confidential. If you are not the intended
recipient of this message, or if this message has been addressed to you in
error, please immediately alert the sender by reply e-mail and then delete this
message and its attachments. Do not deliver, distribute or copy this message
and/or any attachments and if you are not the intended recipient, do not
disclose the contents or take any action in reliance upon the information
contained in this communication or any attachments.
Thank you