-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
NLog version:
NLog, Version=6.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 6.0.3.4402
Platform:
.NET8 on Windows
Current NLog config
// Log file target
var logfile = new FileTarget()
{
Name = "logfile",
FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MXdiags", "MxDiags.log"),
ArchiveSuffixFormat = "{1:-yyMMdd-HHmmss}",
ArchiveAboveSize = configFile.runtimeOptions.configProperties.LogFileSize,
ArchiveOldFileOnStartup = true,
MaxArchiveFiles = configFile.runtimeOptions.configProperties.LogFileCount,
Layout = "${longdate}|${level}| ${message}",
Footer = "------ LOG CLOSED ${longdate} ------"
};
// Async wrapper
var asyncLogFile = new AsyncTargetWrapper()
{
WrappedTarget = logfile,
Name = "MxDiags",
OverflowAction = AsyncTargetWrapperOverflowAction.Discard,
QueueLimit = 10000,
BatchSize = 200,
TimeToSleepBetweenBatches = 1
};
// Config
var config = new LoggingConfiguration();
config.AddRule(LogLevel.Trace, LogLevel.Fatal, asyncLogFile, "CMX", !Debugger.IsAttached);
// Debugging?
if (Debugger.IsAttached)
{
// debugger
var debugger = new DebuggerTarget()
{
Layout = "${time} ${message}"
};
config.AddRule(LogLevel.Trace, LogLevel.Fatal, debugger, "CMX", true);
}
NLog.Common.InternalLogger.LogLevel = LogLevel.Debug;
NLog.Common.InternalLogger.LogFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "MXdiags", "nlog-internal.txt");
// Apply configuration
LogManager.Configuration = config;
LogManager.AutoShutdown = false;- What is the current result?
The logging works as expected when my program is run from the command line.
When run as a Windows Service using SYSTEM context, only the main log file is created. On starting the program the existing main log file is not archived, and it recreates the main log file when it reaches 2MB rather than 12MB, again no archive is created.
-
What is the expected result?
The log file will be archived on program start.
the log file will be archived when it reaches 12MB. -
Did you check the Internal log?
Yes. See message below -
Please post full exception details (message, stacktrace, inner exceptions)
No errors reported. -
Are there any workarounds?
No. -
Is there a version in which it did work?
Only tried v6