Skip to content

Commit

Permalink
Include scope properties (#210)
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Chang <vicchang@nvidia.com>
  • Loading branch information
mocsharp authored Oct 13, 2022
1 parent 9068fc7 commit c1e036a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/InformaticsGateway/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ internal static IHostBuilder CreateHostBuilder(string[] args) =>

private static NLog.Logger ConfigureNLog(string assemblyVersionNumber)
{
LayoutRenderer.Register("servicename", logEvent => Assembly.GetEntryAssembly()?.GetName().Name);
LayoutRenderer.Register("servicename", logEvent => typeof(Program).Namespace);
LayoutRenderer.Register("serviceversion", logEvent => assemblyVersionNumber);
LayoutRenderer.Register("machinename", logEvent => Environment.MachineName);

Expand Down
7 changes: 4 additions & 3 deletions src/InformaticsGateway/nlog.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<!--
<?xml version="1.0" encoding="utf-8" ?>

<!--
Copyright 2022 MONAI Consortium
Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -14,7 +16,6 @@ See the License for the specific language governing permissions and
limitations under the License.
-->

<?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"
autoReload="true"
Expand Down Expand Up @@ -47,7 +48,7 @@ limitations under the License.
<target xsi:type="ColoredConsole" name="lifetimeConsole" layout="${longdate}|${event-properties:item=EventId:whenEmpty=0}|${uppercase:${level}}|${logger}|${scopenested}|${message} ${exception:format=tostring}" />

<target name="logstash" xsi:type="Network" address="${environment:LOGSTASH_URL}" newLine="true">
<layout xsi:type="JsonLayout" includeAllProperties="true" >
<layout xsi:type="JsonLayout" IncludeEventProperties="true" IncludeScopeProperties="true">
<attribute name="Tag" layout="${environment:ENVIRONMENT_NAME}" />
<attribute name="ServiceName" layout="${servicename}" />
<attribute name="ServiceVersion" layout="${serviceversion}" />
Expand Down

0 comments on commit c1e036a

Please sign in to comment.