You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-dev@logging.apache.org by "eryw456f2345t (JIRA)" <ji...@apache.org> on 2014/02/27 12:58:19 UTC
[jira] [Updated] (LOG4NET-425) RollingFileAppender create log file
without BOM if log file was deleted runtime
[ https://issues.apache.org/jira/browse/LOG4NET-425?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
eryw456f2345t updated LOG4NET-425:
----------------------------------
Description:
RollingFileAppender create log file without Unicode Byte Order Mark if log file was deleted runtime.
Example of program:
{code:CSharp}
using System;
using System.IO;
using log4net;
using log4net.Config;
namespace log4net_test
{
public class Program
{
public static void Main(string[] args)
{
var log4net_config_file_path = Path.Combine(Environment.CurrentDirectory, "log.config");
File.WriteAllText(log4net_config_file_path, Config);
GlobalContext.Properties["logDir"] = Environment.CurrentDirectory;
var log4net_config = new FileInfo(log4net_config_file_path);
XmlConfigurator.ConfigureAndWatch(log4net_config);
var log_file = new FileInfo(Path.Combine(Environment.CurrentDirectory, "log.log"));
var log = LogManager.GetLogger(typeof(Program));
log.InfoFormat("Сообщение {0}", 1); // log with Unicode BOM
log_file.Delete(); // delete log
log.InfoFormat("Сообщение {0}", 2); // log without Unicode BOM
}
private static string Config
{
get
{
return
@"<?xml version=""1.0"" encoding=""utf-8"" ?>
<log4net>
<appender name=""MainAppender"" type=""log4net.Appender.RollingFileAppender"">
<file type=""log4net.Util.PatternString"" value=""%property{logDir}/log.log"" />
<lockingModel type=""log4net.Appender.FileAppender+MinimalLock"" />
<appendToFile value=""true"" />
<encoding value=""utf-8"" />
<rollingStyle value=""Size"" />
<maxSizeRollBackups value=""10"" />
<maximumFileSize value=""5MB"" />
<PreserveLogFileNameExtension value=""true"" />
<staticLogFileName value=""true"" />
<layout type=""log4net.Layout.PatternLayout"">
<conversionPattern value=""%date [%thread] %-5level %logger - %message%newline%exception#End%newline"" />
</layout>
</appender>
<root>
<appender-ref ref=""MainAppender"" />
</root>
</log4net>";
}
}
}
}
{code}
was:
RollingFileAppender create log file without BOM if log file was deleted runtime.
Example of program:
{code:CSharp}
using System;
using System.IO;
using log4net;
using log4net.Config;
namespace log4net_test
{
public class Program
{
public static void Main(string[] args)
{
var log4net_config_file_path = Path.Combine(Environment.CurrentDirectory, "log.config");
File.WriteAllText(log4net_config_file_path, Config);
GlobalContext.Properties["logDir"] = Environment.CurrentDirectory;
var log4net_config = new FileInfo(log4net_config_file_path);
XmlConfigurator.ConfigureAndWatch(log4net_config);
var log_file = new FileInfo(Path.Combine(Environment.CurrentDirectory, "log.log"));
var log = LogManager.GetLogger(typeof(Program));
log.InfoFormat("Сообщение {0}", 1); // log with Unicode BOM
log_file.Delete(); // delete log
log.InfoFormat("Сообщение {0}", 2); // log without Unicode BOM
}
private static string Config
{
get
{
return
@"<?xml version=""1.0"" encoding=""utf-8"" ?>
<log4net>
<appender name=""MainAppender"" type=""log4net.Appender.RollingFileAppender"">
<file type=""log4net.Util.PatternString"" value=""%property{logDir}/log.log"" />
<lockingModel type=""log4net.Appender.FileAppender+MinimalLock"" />
<appendToFile value=""true"" />
<encoding value=""utf-8"" />
<rollingStyle value=""Size"" />
<maxSizeRollBackups value=""10"" />
<maximumFileSize value=""5MB"" />
<PreserveLogFileNameExtension value=""true"" />
<staticLogFileName value=""true"" />
<layout type=""log4net.Layout.PatternLayout"">
<conversionPattern value=""%date [%thread] %-5level %logger - %message%newline%exception#End%newline"" />
</layout>
</appender>
<root>
<appender-ref ref=""MainAppender"" />
</root>
</log4net>";
}
}
}
}
{code}
> RollingFileAppender create log file without BOM if log file was deleted runtime
> -------------------------------------------------------------------------------
>
> Key: LOG4NET-425
> URL: https://issues.apache.org/jira/browse/LOG4NET-425
> Project: Log4net
> Issue Type: Bug
> Components: Appenders
> Affects Versions: 1.2.11, 1.2.12, 1.2.13
> Environment: Windows 7 x64, .NET 4
> Reporter: eryw456f2345t
> Priority: Minor
>
> RollingFileAppender create log file without Unicode Byte Order Mark if log file was deleted runtime.
> Example of program:
> {code:CSharp}
> using System;
> using System.IO;
> using log4net;
> using log4net.Config;
> namespace log4net_test
> {
> public class Program
> {
> public static void Main(string[] args)
> {
> var log4net_config_file_path = Path.Combine(Environment.CurrentDirectory, "log.config");
> File.WriteAllText(log4net_config_file_path, Config);
> GlobalContext.Properties["logDir"] = Environment.CurrentDirectory;
> var log4net_config = new FileInfo(log4net_config_file_path);
> XmlConfigurator.ConfigureAndWatch(log4net_config);
> var log_file = new FileInfo(Path.Combine(Environment.CurrentDirectory, "log.log"));
> var log = LogManager.GetLogger(typeof(Program));
> log.InfoFormat("Сообщение {0}", 1); // log with Unicode BOM
> log_file.Delete(); // delete log
> log.InfoFormat("Сообщение {0}", 2); // log without Unicode BOM
> }
> private static string Config
> {
> get
> {
> return
> @"<?xml version=""1.0"" encoding=""utf-8"" ?>
> <log4net>
> <appender name=""MainAppender"" type=""log4net.Appender.RollingFileAppender"">
> <file type=""log4net.Util.PatternString"" value=""%property{logDir}/log.log"" />
> <lockingModel type=""log4net.Appender.FileAppender+MinimalLock"" />
> <appendToFile value=""true"" />
> <encoding value=""utf-8"" />
> <rollingStyle value=""Size"" />
> <maxSizeRollBackups value=""10"" />
> <maximumFileSize value=""5MB"" />
> <PreserveLogFileNameExtension value=""true"" />
> <staticLogFileName value=""true"" />
> <layout type=""log4net.Layout.PatternLayout"">
> <conversionPattern value=""%date [%thread] %-5level %logger - %message%newline%exception#End%newline"" />
> </layout>
> </appender>
> <root>
> <appender-ref ref=""MainAppender"" />
> </root>
> </log4net>";
> }
> }
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)