Skip to content

Log4JXmlEventLayout issue with file target #5914

@WLHodges

Description

@WLHodges

Platform: net9.0-windows
NLog version: 6.0.1
NLog.Targets.Network: 6.0.1

This config file was working (prior to v6 I think). Also, each target works individually. This can be proven by commenting out either target along with its extension and rule. Together the following exception is thrown - "NLog.Targets.Log4JXmlTarget Address-property must be assigned. Address is needed for network destination."
Removing just the "NLog.Targets.Network" extension also throws an exception.

<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"
	  internalLogLevel="Trace"
	  internalLogFile="c:\temp\nlog-internal.log"
	  throwExceptions="true"
	  throwConfigExceptions="true" >

	<extensions>
		<add assembly="NlogTest"/>
		<add assembly="NLog.Targets.Network"/>
	</extensions>

	<targets>
		<target name="logViewer" xsi:type="NLogViewer" />
		<target name="file" xsi:type="File"
		        fileName="${basedir}/logs/${date:format=yyyy-MM-dd}.log"
		        createDirs="true"
		        keepFileOpen="true"
		        encoding="utf-8"
		        archiveAboveSize="5120000"
		        archiveOldFileOnStartup="false"
		        maxArchiveFiles="90">
			<layout xsi:type="Log4JXmlEventLayout"
					includeEventProperties="true"/>
		</target>
	</targets>

	<rules>
		<logger name="*" minLevel="Info" writeTo="logViewer"/>
		<logger name="*" minlevel="Debug" writeTo="file"/>
	</rules>
</nlog>

NlogTest.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions