У меня наблюдается следующее поведение:
В разработке (локальной) нет проблем с регистрацией исключений, все виды работ.
КогдаЯ вошел в систему на удаленном сервере (с помощью подключения к удаленному рабочему столу) и открыл Chrome внутри сервера и создал исключение, также нет проблем, все виды журналирования работают.
Если я используюмой ноутбук и браузер Chrome, чтобы открыть тот же веб-сайт, который размещен на сервере:
Контроллер / Действие
{
// log record gets created for the following line
logger.Log(LogLevel.Fatal, "Sample informational message");
// log record not created. However this record get created in item 1 and 2 case above
int a = int.Parse("A");
}
Global.asax
protected void Application_Error(object sender, EventArgs e)
{
Logger logger = LogManager.GetCurrentClassLogger();
logger.Fatal(Server.GetLastError());
Server.ClearError();
}
NLog.config
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off"
internalLogFile="D:\...\logs\nlog-internal.log">
<!--Define Various Log Targets like files, database or asp.net trace files-->
<targets>
<target name="console" xsi:type="ColoredConsole" layout="${message}" />
<!--Write logs to File where we want to write error logs-->
<target name="file"
archiveFileName="logs/archives/app-log.{#}.txt"
archiveEvery="Day"
archiveNumbering="Rolling"
maxArchiveFiles="7"
xsi:type="File"
fileName="D:\...\logs\ErrorLogFile.log"
layout="--------------------- ${level} (${longdate}) ${machinename} --------------------
${newline}
${newline}
Additional Info : ${message}${newline}
Exception Type : ${exception:format=Type}${newline}
Exception Message: ${exception:format=Message}${newline}
Stack Trace : ${exception:format=Stack Trace}${newline}
">
</target>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="file" />
</rules>
</nlog>
internalLogLevel = "Debug" вывод:
2018-09-20 19:26:10.4825 Debug ScanAssembly('NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c')
2018-09-20 19:26:10.5275 Debug Search for auto loading files, location: C:\inetpub\wwwroot\Test
2018-09-20 19:26:10.5275 Debug Start auto loading, location: C:\inetpub\wwwroot\Test
2018-09-20 19:26:10.5345 Debug Auto loading done
2018-09-20 19:26:10.5345 Info Message Template Auto Format enabled
2018-09-20 19:26:10.5345 Debug Setting 'UppercaseLayoutRendererWrapper.uppercase' to 'true'
2018-09-20 19:26:10.5345 Debug Setting 'ColoredConsoleTarget.name' to 'console'
2018-09-20 19:26:10.5345 Debug Setting 'ColoredConsoleTarget.layout' to '${message}'
2018-09-20 19:26:10.5345 Info Adding target ColoredConsole Target[console]
2018-09-20 19:26:10.5345 Debug Registered target console: NLog.Targets.ColoredConsoleTarget
2018-09-20 19:26:10.5525 Debug Setting 'UppercaseLayoutRendererWrapper.uppercase' to 'true'
2018-09-20 19:26:10.5525 Debug Setting 'FileTarget.name' to 'file'
2018-09-20 19:26:10.5525 Debug Setting 'FileTarget.archiveFileName' to 'logs/archives/app-log.{#}.txt'
2018-09-20 19:26:10.5525 Debug Setting 'FileTarget.archiveEvery' to 'Day'
2018-09-20 19:26:10.5525 Debug Setting 'FileTarget.archiveNumbering' to 'Rolling'
2018-09-20 19:26:10.5525 Debug Setting 'FileTarget.maxArchiveFiles' to '7'
2018-09-20 19:26:10.5525 Debug Setting 'FileTarget.fileName' to 'C:\temp\logs\ErrorLogFile.log'
2018-09-20 19:26:10.5525 Debug Setting 'FileTarget.layout' to '--------------------- ${level} (${longdate}) ${machinename} -------------------- ${newline} ${newline} Additional Info : ${message}${newline} Exception Type : ${exception:format=Type}${newline} Exception Message: ${exception:format=Message}${newline} Stack Trace : ${exception:format=Stack Trace}${newline} '
2018-09-20 19:26:10.5795 Debug Setting 'ExceptionLayoutRenderer.format' to 'Type'
2018-09-20 19:26:10.5815 Debug Setting 'ExceptionLayoutRenderer.format' to 'Message'
2018-09-20 19:26:10.5815 Debug Setting 'ExceptionLayoutRenderer.format' to 'Stack Trace'
2018-09-20 19:26:10.5815 Info Adding target File Target[file]
2018-09-20 19:26:10.5815 Debug Registered target file: NLog.Targets.FileTarget
2018-09-20 19:26:10.5815 Info Configured from an XML element in C:\inetpub\wwwroot\Test\NLog.config...
2018-09-20 19:26:10.5815 Debug Unused target checking is started... Rule Count: 1, Target Count: 2
2018-09-20 19:26:10.5815 Warn Unused target detected. Add a rule for this target to the configuration. TargetName: console
2018-09-20 19:26:10.5815 Debug Unused target checking is completed. Total Rule Count: 1, Total Target Count: 2, Unused Target Count: 1
2018-09-20 19:26:10.5815 Debug --- NLog configuration dump ---
2018-09-20 19:26:10.5815 Debug Targets:
2018-09-20 19:26:10.5815 Debug ColoredConsole Target[console]
2018-09-20 19:26:10.5815 Debug File Target[file]
2018-09-20 19:26:10.5815 Debug Rules:
2018-09-20 19:26:10.5815 Debug logNamePattern: (:All) levels: [ Trace Debug Info Warn Error Fatal ] appendTo: [ file ]
2018-09-20 19:26:10.5815 Debug --- End of NLog configuration dump ---
2018-09-20 19:26:10.5815 Info Found 23 configuration items
2018-09-20 19:26:10.6105 Debug Watching path 'C:\inetpub\wwwroot\Test' filter 'NLog.config' for changes.
2018-09-20 19:26:10.6115 Info Configuration initialized.
2018-09-20 19:26:10.6115 Info NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c. File version: 4.5.7.7958. Product version: 4.5.7.
2018-09-20 19:26:10.6115 Debug Targets for Data.Repositories.CommonRepository by level:
2018-09-20 19:26:10.6115 Debug Trace => file
2018-09-20 19:26:10.6115 Debug Debug => file
2018-09-20 19:26:10.6115 Debug Info => file
2018-09-20 19:26:10.6115 Debug Warn => file
2018-09-20 19:26:10.6115 Debug Error => file
2018-09-20 19:26:10.6115 Debug Fatal => file
2018-09-20 19:26:10.6405 Debug Targets for Emailer.EmailManager by level:
2018-09-20 19:26:10.6405 Debug Trace => file
2018-09-20 19:26:10.6405 Debug Debug => file
2018-09-20 19:26:10.6405 Debug Info => file
2018-09-20 19:26:10.6405 Debug Warn => file
2018-09-20 19:26:10.6405 Debug Error => file
2018-09-20 19:26:10.6405 Debug Fatal => file
2018-09-20 19:26:10.6435 Debug Targets for UI.Controllers.BaseController by level:
2018-09-20 19:26:10.6435 Debug Trace => file
2018-09-20 19:26:10.6435 Debug Debug => file
2018-09-20 19:26:10.6435 Debug Info => file
2018-09-20 19:26:10.6435 Debug Warn => file
2018-09-20 19:26:10.6435 Debug Error => file
2018-09-20 19:26:10.6435 Debug Fatal => file
2018-09-20 19:26:10.7735 Debug FileTarget(Name=file): Process file 'C:\temp\logs\ErrorLogFile.log' on startup
2018-09-20 19:26:10.7735 Debug Creating file appender: C:\temp\logs\ErrorLogFile.log
Проект MVC 5..Net 4.5.2.NLog версия 4.5.7
Я также использую SignalR в проекте.Папка журнала имеет права на изменение IIS_IUSRS.
Любая помощь приветствуется.