Async logging
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
<variable name="logStamp" value="${time} ${pad:padding=-8:inner=[${level:uppercase=true}]}" />
|
<variable name="logStamp" value="${time} ${pad:padding=-8:inner=[${level:uppercase=true}]}" />
|
||||||
<variable name="logContent" value="${message:withException=true}"/>
|
<variable name="logContent" value="${message:withException=true}"/>
|
||||||
|
|
||||||
<targets>
|
<targets async="true">
|
||||||
<target xsi:type="Null" name="null" formatMessage="false" />
|
<target xsi:type="Null" name="null" formatMessage="false" />
|
||||||
<target xsi:type="File" name="keen" layout="${var:logStamp} ${logger}: ${var:logContent}" fileName="Logs\Keen-${shortdate}.log" />
|
<target xsi:type="File" name="keen" layout="${var:logStamp} ${logger}: ${var:logContent}" fileName="Logs\Keen-${shortdate}.log" />
|
||||||
<target xsi:type="File" name="main" layout="${var:logStamp} ${logger}: ${var:logContent}" fileName="Logs\Torch-${shortdate}.log" />
|
<target xsi:type="File" name="main" layout="${var:logStamp} ${logger}: ${var:logContent}" fileName="Logs\Torch-${shortdate}.log" />
|
||||||
|
@@ -14,6 +14,7 @@ using System.Windows.Media.Imaging;
|
|||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
using NLog;
|
using NLog;
|
||||||
|
using NLog.Targets.Wrappers;
|
||||||
using Sandbox;
|
using Sandbox;
|
||||||
using Torch.API;
|
using Torch.API;
|
||||||
using Torch.API.Managers;
|
using Torch.API.Managers;
|
||||||
@@ -57,7 +58,13 @@ namespace Torch.Server
|
|||||||
|
|
||||||
private void AttachConsole()
|
private void AttachConsole()
|
||||||
{
|
{
|
||||||
var doc = LogManager.Configuration.FindTargetByName<FlowDocumentTarget>("wpf")?.Document;
|
const string target = "wpf";
|
||||||
|
var doc = LogManager.Configuration.FindTargetByName<FlowDocumentTarget>(target)?.Document;
|
||||||
|
if (doc == null)
|
||||||
|
{
|
||||||
|
var wrapped = LogManager.Configuration.FindTargetByName<WrapperTargetBase>(target);
|
||||||
|
doc = (wrapped?.WrappedTarget as FlowDocumentTarget)?.Document;
|
||||||
|
}
|
||||||
ConsoleText.Document = doc ?? new FlowDocument(new Paragraph(new Run("No target!")));
|
ConsoleText.Document = doc ?? new FlowDocument(new Paragraph(new Run("No target!")));
|
||||||
ConsoleText.TextChanged += (sender, args) => ConsoleText.ScrollToEnd();
|
ConsoleText.TextChanged += (sender, args) => ConsoleText.ScrollToEnd();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user