Config file problem

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Config file problem

Glenn E. Lanier, II
I just re-built my system, so I probably missed putting something back that
is causing this error.

When I try to load the XmlLoggingConfiguration, I get a
System.ArgumentNullException in mscorlib.dll on the new
Nlog.Config.XmlLoggingCOnfiguration line.

Error>(An unhandled exception of type 'System.ArgumentNullException'
occurred in mscorlib.dll
Error>Additional information: Value cannot be null.)
 
I created a new C# Windows application (using VS 2003). In Main(), I am
trying to initialize my logger object using the code below. I know sFile
exists, because I check beforehand.

Code>NLog.Config.XmlLoggingConfiguration xlc = new
NLog.Config.XmlLoggingConfiguration(sFile);
Code>LogManager.Configuration = xlc;
Code>logger.Info("TB Tests Database program starting");

Elsewhere, I have:

Code>static Logger logger = LogManager.GetLogger("formMain");

(not that it matters at this point).

 
Complete contents of log.config are:
------ log.config begin ------
<configuration>
   <configSections>
      <section name="nlog" type="NLog.Config.ConfigSectionhandler, NLog" />
   </configSections>
   <nlog autoReload="true">
      <targets>
         <target name="console" type="Console"
layout="${longdate}|${machinename}|${windows-identity}|${level:uppercase=tru
e}|${logger}|${message}" />
         <target name="AuditLog" type="File"
filename="${basedir}/logs/aud/${date:format=yyyy.MM}-Audit.log"
CreateDirs="true"
layout="${longdate}|${machinename}|${windows-identity}|${level:uppercase=tru
e}|${logger}|${message}" />
         <target name="GenLog" type="File"
filename="${basedir}/logs/gen/${date:format=yyyy.MM.dd}-General.log"
CreateDirs="true"
layout="${longdate}|${machinename}|${windows-identity}|${level:uppercase=tru
e}|${logger}|${message}|${callsite}" />
         <target name="ErrorLog" type="File"
filename="${basedir}/logs/err/${date:format=yyyy.MM}-MonthlyErrors.log"
CreateDirs="true"
layout="${longdate}|${machinename}|${windows-identity}|${level:uppercase=tru
e}|${logger}|${message}|${callsite}" />
         <target name="viewer" type="NLogViewer"
address="udp://localhost:4000" />
      </targets>
      <rules>
         <logger name="*" levels="Error,Fatal" writeTo="ErrorLog" />
         <logger name="Import" levels="Info,Warn,Error,Debug,Fatal"
writeTo="GenLog" final="true" />
         <logger name="Audit" levels="Info,Warn,Error,Debug,Fatal"
writeTo="AuditLog" />
         <logger name="*" levels="Info,Warn,Error,Debug,Fatal,Trace"
writeTo="Console, GenLog" />
      </rules>
   </nlog>
</configuration>
------ log.config end -------

Any help would be greatly appreciated.

Thanks.

--G



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list
Reply | Threaded
Open this post in threaded view
|

Re: Config file problem

Jarek Kowalski
Administrator
Can you send the entire exception, along with the stack trace? My initial
idea is that you're passing the wrong path.

Jarek
----- Original Message -----
From: "Glenn E. Lanier, II" <[hidden email]>
To: <[hidden email]>
Sent: Friday, February 17, 2006 4:00 PM
Subject: [Nlog-list] Config file problem


>I just re-built my system, so I probably missed putting something back that
> is causing this error.
>
> When I try to load the XmlLoggingConfiguration, I get a
> System.ArgumentNullException in mscorlib.dll on the new
> Nlog.Config.XmlLoggingCOnfiguration line.
>
> Error>(An unhandled exception of type 'System.ArgumentNullException'
> occurred in mscorlib.dll
> Error>Additional information: Value cannot be null.)
>
> I created a new C# Windows application (using VS 2003). In Main(), I am
> trying to initialize my logger object using the code below. I know sFile
> exists, because I check beforehand.
>
> Code>NLog.Config.XmlLoggingConfiguration xlc = new
> NLog.Config.XmlLoggingConfiguration(sFile);
> Code>LogManager.Configuration = xlc;
> Code>logger.Info("TB Tests Database program starting");
>
> Elsewhere, I have:
>
> Code>static Logger logger = LogManager.GetLogger("formMain");
>
> (not that it matters at this point).
>
>
> Complete contents of log.config are:
> ------ log.config begin ------
> <configuration>
>   <configSections>
>      <section name="nlog" type="NLog.Config.ConfigSectionhandler, NLog" />
>   </configSections>
>   <nlog autoReload="true">
>      <targets>
>         <target name="console" type="Console"
> layout="${longdate}|${machinename}|${windows-identity}|${level:uppercase=tru
> e}|${logger}|${message}" />
>         <target name="AuditLog" type="File"
> filename="${basedir}/logs/aud/${date:format=yyyy.MM}-Audit.log"
> CreateDirs="true"
> layout="${longdate}|${machinename}|${windows-identity}|${level:uppercase=tru
> e}|${logger}|${message}" />
>         <target name="GenLog" type="File"
> filename="${basedir}/logs/gen/${date:format=yyyy.MM.dd}-General.log"
> CreateDirs="true"
> layout="${longdate}|${machinename}|${windows-identity}|${level:uppercase=tru
> e}|${logger}|${message}|${callsite}" />
>         <target name="ErrorLog" type="File"
> filename="${basedir}/logs/err/${date:format=yyyy.MM}-MonthlyErrors.log"
> CreateDirs="true"
> layout="${longdate}|${machinename}|${windows-identity}|${level:uppercase=tru
> e}|${logger}|${message}|${callsite}" />
>         <target name="viewer" type="NLogViewer"
> address="udp://localhost:4000" />
>      </targets>
>      <rules>
>         <logger name="*" levels="Error,Fatal" writeTo="ErrorLog" />
>         <logger name="Import" levels="Info,Warn,Error,Debug,Fatal"
> writeTo="GenLog" final="true" />
>         <logger name="Audit" levels="Info,Warn,Error,Debug,Fatal"
> writeTo="AuditLog" />
>         <logger name="*" levels="Info,Warn,Error,Debug,Fatal,Trace"
> writeTo="Console, GenLog" />
>      </rules>
>   </nlog>
> </configuration>
> ------ log.config end -------
>
> Any help would be greatly appreciated.
>
> Thanks.
>
> --G
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Nlog-list mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/nlog-list
>



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list
NLog Blog
Reply | Threaded
Open this post in threaded view
|

RE: Config file problem

Glenn E. Lanier, II
Jarek,

Sure. I get this exception/stack trace

--- NLog XmlLoggingConfiguration Exception ---
System.ArgumentNullException: Value cannot be null.
Parameter name: value
   at System.Collections.CollectionBase.OnValidate(Object value)
   at System.Collections.CollectionBase.System.Collections.IList.Add(Object
value)
   at NLog.TargetCollection.Add(Target value)
   at
NLog.Config.XmlLoggingConfiguration.ConfigureRulesFromElement(LoggingConfigu
ration config, LoggingRuleCollection rules, XmlElement element)
   at NLog.Config.XmlLoggingConfiguration.ConfigureFromXmlElement(XmlElement
configElement, String baseDirectory)
   at NLog.Config.XmlLoggingConfiguration.ConfigureFromFile(String fileName)
   at NLog.Config.XmlLoggingConfiguration..ctor(String fileName)
   at TBTests.formMain.Main() in c:\glenn\lanier
consulting\compucom-1\uab-employee health\tbtest-c#\tbtests\formmain.cs:line
162

generated by the following code:

                        string sFile = "TBTests.logging.config";
                        FileInfo fi = new FileInfo(sFile);
                        if (!fi.Exists)
                        {
                                MessageBox.Show(string.Format("Unable to
find required file {0}", sFile), "Configuration Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return;
                        }

                        try
                        {
                                NLog.Config.XmlLoggingConfiguration xlc =
null;
                                xlc = new
NLog.Config.XmlLoggingConfiguration(sFile);
                                LogManager.Configuration = xlc;
                        }
                        catch (Exception ex)
                        {
                                Console.WriteLine("\n--- NLog
XmlLoggingConfiguration Exception ---\n{0}\n", ex.ToString());
                        }

which is the exact same procedure I've used in the past in other projects (I
simply copied the code). The only difference (that I can tell) is this is
occurring after I re-installed Windows/VS2003/NLog 0.9.

--G

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> Jaroslaw Kowalski
> Sent: Saturday, February 18, 2006 10:42 AM
> To: Glenn E. Lanier, II; [hidden email]
> Subject: Re: [Nlog-list] Config file problem
>
> Can you send the entire exception, along with the stack
> trace? My initial
> idea is that you're passing the wrong path.
>
> Jarek
> ----- Original Message -----
> From: "Glenn E. Lanier, II" <[hidden email]>
> To: <[hidden email]>
> Sent: Friday, February 17, 2006 4:00 PM
> Subject: [Nlog-list] Config file problem
>
>
> >I just re-built my system, so I probably missed putting
> something back that
> > is causing this error.
> >
> > When I try to load the XmlLoggingConfiguration, I get a
> > System.ArgumentNullException in mscorlib.dll on the new
> > Nlog.Config.XmlLoggingCOnfiguration line.
> >
> > Error>(An unhandled exception of type 'System.ArgumentNullException'
> > occurred in mscorlib.dll
> > Error>Additional information: Value cannot be null.)
> >
> > I created a new C# Windows application (using VS 2003). In
> Main(), I am
> > trying to initialize my logger object using the code below.
> I know sFile
> > exists, because I check beforehand.
> >
> > Code>NLog.Config.XmlLoggingConfiguration xlc = new
> > NLog.Config.XmlLoggingConfiguration(sFile);
> > Code>LogManager.Configuration = xlc;
> > Code>logger.Info("TB Tests Database program starting");
> >
> > Elsewhere, I have:
> >
> > Code>static Logger logger = LogManager.GetLogger("formMain");
> >
> > (not that it matters at this point).
> >
> >
> > Complete contents of log.config are:
> > ------ log.config begin ------
> > <configuration>
> >   <configSections>
> >      <section name="nlog"
> type="NLog.Config.ConfigSectionhandler, NLog" />
> >   </configSections>
> >   <nlog autoReload="true">
> >      <targets>
> >         <target name="console" type="Console"
> >
> layout="${longdate}|${machinename}|${windows-identity}|${level
:uppercase=tru
> > e}|${logger}|${message}" />
> >         <target name="AuditLog" type="File"
> > filename="${basedir}/logs/aud/${date:format=yyyy.MM}-Audit.log"
> > CreateDirs="true"
> >
> layout="${longdate}|${machinename}|${windows-identity}|${level
:uppercase=tru
> > e}|${logger}|${message}" />
> >         <target name="GenLog" type="File"
> > filename="${basedir}/logs/gen/${date:format=yyyy.MM.dd}-General.log"
> > CreateDirs="true"
> >
> layout="${longdate}|${machinename}|${windows-identity}|${level
:uppercase=tru
> > e}|${logger}|${message}|${callsite}" />
> >         <target name="ErrorLog" type="File"
> >
> filename="${basedir}/logs/err/${date:format=yyyy.MM}-MonthlyEr
rors.log"
> > CreateDirs="true"
> >
> layout="${longdate}|${machinename}|${windows-identity}|${level
:uppercase=tru

> > e}|${logger}|${message}|${callsite}" />
> >         <target name="viewer" type="NLogViewer"
> > address="udp://localhost:4000" />
> >      </targets>
> >      <rules>
> >         <logger name="*" levels="Error,Fatal" writeTo="ErrorLog" />
> >         <logger name="Import" levels="Info,Warn,Error,Debug,Fatal"
> > writeTo="GenLog" final="true" />
> >         <logger name="Audit" levels="Info,Warn,Error,Debug,Fatal"
> > writeTo="AuditLog" />
> >         <logger name="*" levels="Info,Warn,Error,Debug,Fatal,Trace"
> > writeTo="Console, GenLog" />
> >      </rules>
> >   </nlog>
> > </configuration>
> > ------ log.config end -------
> >
> > Any help would be greatly appreciated.
> >
> > Thanks.
> >
> > --G
> >
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc. Do you grep
> through log
> > files
> > for problems?  Stop!  Download the new AJAX search engine that makes
> > searching your log files as easy as surfing the  web.  
> DOWNLOAD SPLUNK!
> >
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&
dat=121642

> > _______________________________________________
> > Nlog-list mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/nlog-list
> >
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep
> through log files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  
> DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&
dat=121642
> _______________________________________________
> Nlog-list mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/nlog-list
>



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list
Reply | Threaded
Open this post in threaded view
|

Re: Config file problem

Jarek Kowalski
Administrator
Hi Glenn,

1. Most likely you have a reference to a not-existing target in your <logger
/> (somewhere in "appendTo" / "writeTo" attribute)
2. Newer versions of NLog have a check for this condition added and produce
a readable error message.

Please upgrade to the latest published shapshot (preferably from
http://www.nlog-project.org/snapshots/ as this will be the base of the
upcoming 0.95 release) and see if this behavior is fixed.

Jarek

----- Original Message -----
From: "Glenn E. Lanier, II" <[hidden email]>
To: "'Jaroslaw Kowalski'" <[hidden email]>;
<[hidden email]>
Sent: Saturday, February 18, 2006 10:14 PM
Subject: RE: [Nlog-list] Config file problem


> Jarek,
>
> Sure. I get this exception/stack trace
>
> --- NLog XmlLoggingConfiguration Exception ---
> System.ArgumentNullException: Value cannot be null.
> Parameter name: value
>   at System.Collections.CollectionBase.OnValidate(Object value)
>   at System.Collections.CollectionBase.System.Collections.IList.Add(Object
> value)
>   at NLog.TargetCollection.Add(Target value)
>   at
> NLog.Config.XmlLoggingConfiguration.ConfigureRulesFromElement(LoggingConfigu
> ration config, LoggingRuleCollection rules, XmlElement element)
>   at
> NLog.Config.XmlLoggingConfiguration.ConfigureFromXmlElement(XmlElement
> configElement, String baseDirectory)
>   at NLog.Config.XmlLoggingConfiguration.ConfigureFromFile(String
> fileName)
>   at NLog.Config.XmlLoggingConfiguration..ctor(String fileName)
>   at TBTests.formMain.Main() in c:\glenn\lanier
> consulting\compucom-1\uab-employee
> health\tbtest-c#\tbtests\formmain.cs:line
> 162
>
> generated by the following code:
>
> string sFile = "TBTests.logging.config";
> FileInfo fi = new FileInfo(sFile);
> if (!fi.Exists)
> {
> MessageBox.Show(string.Format("Unable to
> find required file {0}", sFile), "Configuration Error",
> MessageBoxButtons.OK, MessageBoxIcon.Error);
> return;
> }
>
> try
> {
> NLog.Config.XmlLoggingConfiguration xlc =
> null;
> xlc = new
> NLog.Config.XmlLoggingConfiguration(sFile);
> LogManager.Configuration = xlc;
> }
> catch (Exception ex)
> {
> Console.WriteLine("\n--- NLog
> XmlLoggingConfiguration Exception ---\n{0}\n", ex.ToString());
> }
>
> which is the exact same procedure I've used in the past in other projects
> (I
> simply copied the code). The only difference (that I can tell) is this is
> occurring after I re-installed Windows/VS2003/NLog 0.9.
>
> --G
>
>> -----Original Message-----
>> From: [hidden email]
>> [mailto:[hidden email]] On Behalf Of
>> Jaroslaw Kowalski
>> Sent: Saturday, February 18, 2006 10:42 AM
>> To: Glenn E. Lanier, II; [hidden email]
>> Subject: Re: [Nlog-list] Config file problem
>>
>> Can you send the entire exception, along with the stack
>> trace? My initial
>> idea is that you're passing the wrong path.
>>
>> Jarek
>> ----- Original Message -----
>> From: "Glenn E. Lanier, II" <[hidden email]>
>> To: <[hidden email]>
>> Sent: Friday, February 17, 2006 4:00 PM
>> Subject: [Nlog-list] Config file problem
>>
>>
>> >I just re-built my system, so I probably missed putting
>> something back that
>> > is causing this error.
>> >
>> > When I try to load the XmlLoggingConfiguration, I get a
>> > System.ArgumentNullException in mscorlib.dll on the new
>> > Nlog.Config.XmlLoggingCOnfiguration line.
>> >
>> > Error>(An unhandled exception of type 'System.ArgumentNullException'
>> > occurred in mscorlib.dll
>> > Error>Additional information: Value cannot be null.)
>> >
>> > I created a new C# Windows application (using VS 2003). In
>> Main(), I am
>> > trying to initialize my logger object using the code below.
>> I know sFile
>> > exists, because I check beforehand.
>> >
>> > Code>NLog.Config.XmlLoggingConfiguration xlc = new
>> > NLog.Config.XmlLoggingConfiguration(sFile);
>> > Code>LogManager.Configuration = xlc;
>> > Code>logger.Info("TB Tests Database program starting");
>> >
>> > Elsewhere, I have:
>> >
>> > Code>static Logger logger = LogManager.GetLogger("formMain");
>> >
>> > (not that it matters at this point).
>> >
>> >
>> > Complete contents of log.config are:
>> > ------ log.config begin ------
>> > <configuration>
>> >   <configSections>
>> >      <section name="nlog"
>> type="NLog.Config.ConfigSectionhandler, NLog" />
>> >   </configSections>
>> >   <nlog autoReload="true">
>> >      <targets>
>> >         <target name="console" type="Console"
>> >
>> layout="${longdate}|${machinename}|${windows-identity}|${level
> :uppercase=tru
>> > e}|${logger}|${message}" />
>> >         <target name="AuditLog" type="File"
>> > filename="${basedir}/logs/aud/${date:format=yyyy.MM}-Audit.log"
>> > CreateDirs="true"
>> >
>> layout="${longdate}|${machinename}|${windows-identity}|${level
> :uppercase=tru
>> > e}|${logger}|${message}" />
>> >         <target name="GenLog" type="File"
>> > filename="${basedir}/logs/gen/${date:format=yyyy.MM.dd}-General.log"
>> > CreateDirs="true"
>> >
>> layout="${longdate}|${machinename}|${windows-identity}|${level
> :uppercase=tru
>> > e}|${logger}|${message}|${callsite}" />
>> >         <target name="ErrorLog" type="File"
>> >
>> filename="${basedir}/logs/err/${date:format=yyyy.MM}-MonthlyEr
> rors.log"
>> > CreateDirs="true"
>> >
>> layout="${longdate}|${machinename}|${windows-identity}|${level
> :uppercase=tru
>> > e}|${logger}|${message}|${callsite}" />
>> >         <target name="viewer" type="NLogViewer"
>> > address="udp://localhost:4000" />
>> >      </targets>
>> >      <rules>
>> >         <logger name="*" levels="Error,Fatal" writeTo="ErrorLog" />
>> >         <logger name="Import" levels="Info,Warn,Error,Debug,Fatal"
>> > writeTo="GenLog" final="true" />
>> >         <logger name="Audit" levels="Info,Warn,Error,Debug,Fatal"
>> > writeTo="AuditLog" />
>> >         <logger name="*" levels="Info,Warn,Error,Debug,Fatal,Trace"
>> > writeTo="Console, GenLog" />
>> >      </rules>
>> >   </nlog>
>> > </configuration>
>> > ------ log.config end -------
>> >
>> > Any help would be greatly appreciated.
>> >
>> > Thanks.
>> >
>> > --G
>> >
>> >
>> >
>> > -------------------------------------------------------
>> > This SF.net email is sponsored by: Splunk Inc. Do you grep
>> through log
>> > files
>> > for problems?  Stop!  Download the new AJAX search engine that makes
>> > searching your log files as easy as surfing the  web.
>> DOWNLOAD SPLUNK!
>> >
>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&
> dat=121642
>> > _______________________________________________
>> > Nlog-list mailing list
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/nlog-list
>> >
>>
>>
>>
>> -------------------------------------------------------
>> This SF.net email is sponsored by: Splunk Inc. Do you grep
>> through log files
>> for problems?  Stop!  Download the new AJAX search engine that makes
>> searching your log files as easy as surfing the  web.
>> DOWNLOAD SPLUNK!
>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&
> dat=121642
>> _______________________________________________
>> Nlog-list mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/nlog-list
>>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Nlog-list mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/nlog-list
>



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list
NLog Blog
Reply | Threaded
Open this post in threaded view
|

RE: Config file problem

Glenn E. Lanier, II
Jarek,

Just installed the latest version, updated references, and bombed again
(after checking to make sure my writeTo was correct).

--- NLog XmlLoggingConfiguration Exception ---
System.ArgumentException: Unknown log level: *
   at NLog.LogLevel.FromString(String s)
   at
NLog.Config.XmlLoggingConfiguration.ConfigureRulesFromElement(LoggingConfigu
ration config, LoggingRuleCollection rules, XmlElement element)
   at NLog.Config.XmlLoggingConfiguration.ConfigureFromXmlElement(XmlElement
configElement, String baseDirectory)
   at NLog.Config.XmlLoggingConfiguration.ConfigureFromFile(String fileName)
   at NLog.Config.XmlLoggingConfiguration..ctor(String fileName)
   at TBTests.formMain.Main() in c:\glenn\lanier
consulting\compucom-1\uab-employee health\tbtest-c#\tbtests\formmain.cs:line
162

Sure enough, my <rules> contained

   <logger name="*" levels="*" writeTo="Console, GenLog" />

instead of

   <logger name="*" levels="Info,Warn,Error,Debug,Fatal,Trace"
writeTo="Console, GenLog" />

I saw that I could use * for the name, so I _incorrectly_ *assumed* that I
could also use it for the levels.

As soon as I made the change and tried again, it worked. Sorry for making
such a stupid mistake public! Thanks for your help.

--G


> -----Original Message-----
> From: Jaroslaw Kowalski [mailto:[hidden email]]
> Sent: Saturday, February 18, 2006 3:26 PM
> To: Glenn E. Lanier, II; [hidden email]
> Subject: Re: [Nlog-list] Config file problem
>
> Hi Glenn,
>
> 1. Most likely you have a reference to a not-existing target
> in your <logger
> /> (somewhere in "appendTo" / "writeTo" attribute)
> 2. Newer versions of NLog have a check for this condition
> added and produce
> a readable error message.
>
> Please upgrade to the latest published shapshot (preferably from
> http://www.nlog-project.org/snapshots/ as this will be the
> base of the
> upcoming 0.95 release) and see if this behavior is fixed.
>
> Jarek
>
> ----- Original Message -----
> From: "Glenn E. Lanier, II" <[hidden email]>
> To: "'Jaroslaw Kowalski'" <[hidden email]>;
> <[hidden email]>
> Sent: Saturday, February 18, 2006 10:14 PM
> Subject: RE: [Nlog-list] Config file problem
>
>
> > Jarek,
> >
> > Sure. I get this exception/stack trace
> >
> > --- NLog XmlLoggingConfiguration Exception ---
> > System.ArgumentNullException: Value cannot be null.
> > Parameter name: value
> >   at System.Collections.CollectionBase.OnValidate(Object value)
> >   at
> System.Collections.CollectionBase.System.Collections.IList.Add(Object
> > value)
> >   at NLog.TargetCollection.Add(Target value)
> >   at
> >
> NLog.Config.XmlLoggingConfiguration.ConfigureRulesFromElement(
> LoggingConfigu
> > ration config, LoggingRuleCollection rules, XmlElement element)
> >   at
> >
> NLog.Config.XmlLoggingConfiguration.ConfigureFromXmlElement(XmlElement
> > configElement, String baseDirectory)
> >   at NLog.Config.XmlLoggingConfiguration.ConfigureFromFile(String
> > fileName)
> >   at NLog.Config.XmlLoggingConfiguration..ctor(String fileName)
> >   at TBTests.formMain.Main() in c:\glenn\lanier
> > consulting\compucom-1\uab-employee
> > health\tbtest-c#\tbtests\formmain.cs:line
> > 162
> >
> > generated by the following code:
> >
> > string sFile = "TBTests.logging.config";
> > FileInfo fi = new FileInfo(sFile);
> > if (!fi.Exists)
> > {
> > MessageBox.Show(string.Format("Unable to
> > find required file {0}", sFile), "Configuration Error",
> > MessageBoxButtons.OK, MessageBoxIcon.Error);
> > return;
> > }
> >
> > try
> > {
> > NLog.Config.XmlLoggingConfiguration xlc =
> > null;
> > xlc = new
> > NLog.Config.XmlLoggingConfiguration(sFile);
> > LogManager.Configuration = xlc;
> > }
> > catch (Exception ex)
> > {
> > Console.WriteLine("\n--- NLog
> > XmlLoggingConfiguration Exception ---\n{0}\n", ex.ToString());
> > }
> >
> > which is the exact same procedure I've used in the past in
> other projects
> > (I
> > simply copied the code). The only difference (that I can
> tell) is this is
> > occurring after I re-installed Windows/VS2003/NLog 0.9.
> >
> > --G
> >
> >> -----Original Message-----
> >> From: [hidden email]
> >> [mailto:[hidden email]] On Behalf Of
> >> Jaroslaw Kowalski
> >> Sent: Saturday, February 18, 2006 10:42 AM
> >> To: Glenn E. Lanier, II; [hidden email]
> >> Subject: Re: [Nlog-list] Config file problem
> >>
> >> Can you send the entire exception, along with the stack
> >> trace? My initial
> >> idea is that you're passing the wrong path.
> >>
> >> Jarek
> >> ----- Original Message -----
> >> From: "Glenn E. Lanier, II" <[hidden email]>
> >> To: <[hidden email]>
> >> Sent: Friday, February 17, 2006 4:00 PM
> >> Subject: [Nlog-list] Config file problem
> >>
> >>
> >> >I just re-built my system, so I probably missed putting
> >> something back that
> >> > is causing this error.
> >> >
> >> > When I try to load the XmlLoggingConfiguration, I get a
> >> > System.ArgumentNullException in mscorlib.dll on the new
> >> > Nlog.Config.XmlLoggingCOnfiguration line.
> >> >
> >> > Error>(An unhandled exception of type
> 'System.ArgumentNullException'
> >> > occurred in mscorlib.dll
> >> > Error>Additional information: Value cannot be null.)
> >> >
> >> > I created a new C# Windows application (using VS 2003). In
> >> Main(), I am
> >> > trying to initialize my logger object using the code below.
> >> I know sFile
> >> > exists, because I check beforehand.
> >> >
> >> > Code>NLog.Config.XmlLoggingConfiguration xlc = new
> >> > NLog.Config.XmlLoggingConfiguration(sFile);
> >> > Code>LogManager.Configuration = xlc;
> >> > Code>logger.Info("TB Tests Database program starting");
> >> >
> >> > Elsewhere, I have:
> >> >
> >> > Code>static Logger logger = LogManager.GetLogger("formMain");
> >> >
> >> > (not that it matters at this point).
> >> >
> >> >
> >> > Complete contents of log.config are:
> >> > ------ log.config begin ------
> >> > <configuration>
> >> >   <configSections>
> >> >      <section name="nlog"
> >> type="NLog.Config.ConfigSectionhandler, NLog" />
> >> >   </configSections>
> >> >   <nlog autoReload="true">
> >> >      <targets>
> >> >         <target name="console" type="Console"
> >> >
> >> layout="${longdate}|${machinename}|${windows-identity}|${level
> > :uppercase=tru
> >> > e}|${logger}|${message}" />
> >> >         <target name="AuditLog" type="File"
> >> > filename="${basedir}/logs/aud/${date:format=yyyy.MM}-Audit.log"
> >> > CreateDirs="true"
> >> >
> >> layout="${longdate}|${machinename}|${windows-identity}|${level
> > :uppercase=tru
> >> > e}|${logger}|${message}" />
> >> >         <target name="GenLog" type="File"
> >> >
> filename="${basedir}/logs/gen/${date:format=yyyy.MM.dd}-General.log"
> >> > CreateDirs="true"
> >> >
> >> layout="${longdate}|${machinename}|${windows-identity}|${level
> > :uppercase=tru
> >> > e}|${logger}|${message}|${callsite}" />
> >> >         <target name="ErrorLog" type="File"
> >> >
> >> filename="${basedir}/logs/err/${date:format=yyyy.MM}-MonthlyEr
> > rors.log"
> >> > CreateDirs="true"
> >> >
> >> layout="${longdate}|${machinename}|${windows-identity}|${level
> > :uppercase=tru
> >> > e}|${logger}|${message}|${callsite}" />
> >> >         <target name="viewer" type="NLogViewer"
> >> > address="udp://localhost:4000" />
> >> >      </targets>
> >> >      <rules>
> >> >         <logger name="*" levels="Error,Fatal"
> writeTo="ErrorLog" />
> >> >         <logger name="Import"
> levels="Info,Warn,Error,Debug,Fatal"
> >> > writeTo="GenLog" final="true" />
> >> >         <logger name="Audit" levels="Info,Warn,Error,Debug,Fatal"
> >> > writeTo="AuditLog" />
> >> >         <logger name="*"
> levels="Info,Warn,Error,Debug,Fatal,Trace"
> >> > writeTo="Console, GenLog" />
> >> >      </rules>
> >> >   </nlog>
> >> > </configuration>
> >> > ------ log.config end -------
> >> >
> >> > Any help would be greatly appreciated.
> >> >
> >> > Thanks.
> >> >
> >> > --G
> >> >
> >> >
> >> >
> >> > -------------------------------------------------------
> >> > This SF.net email is sponsored by: Splunk Inc. Do you grep
> >> through log
> >> > files
> >> > for problems?  Stop!  Download the new AJAX search
> engine that makes
> >> > searching your log files as easy as surfing the  web.
> >> DOWNLOAD SPLUNK!
> >> >
> >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&
> > dat=121642
> >> > _______________________________________________
> >> > Nlog-list mailing list
> >> > [hidden email]
> >> > https://lists.sourceforge.net/lists/listinfo/nlog-list
> >> >
> >>
> >>
> >>
> >> -------------------------------------------------------
> >> This SF.net email is sponsored by: Splunk Inc. Do you grep
> >> through log files
> >> for problems?  Stop!  Download the new AJAX search engine
> that makes
> >> searching your log files as easy as surfing the  web.
> >> DOWNLOAD SPLUNK!
> >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&
> > dat=121642
> >> _______________________________________________
> >> Nlog-list mailing list
> >> [hidden email]
> >> https://lists.sourceforge.net/lists/listinfo/nlog-list
> >>
> >
> >
> >
> > -------------------------------------------------------
> > This SF.net email is sponsored by: Splunk Inc. Do you grep
> through log
> > files
> > for problems?  Stop!  Download the new AJAX search engine that makes
> > searching your log files as easy as surfing the  web.  
> DOWNLOAD SPLUNK!
> >
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&
dat=121642
> > _______________________________________________
> > Nlog-list mailing list
> > [hidden email]
> > https://lists.sourceforge.net/lists/listinfo/nlog-list
> >
>
>



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list
Reply | Threaded
Open this post in threaded view
|

Re: Config file problem

Jarek Kowalski
Administrator
Just a tip: if you omit the levels="..." it means exactly the same thing.

You can use the following attributes to specify levels:

minlevel - minimum level
maxlevel - maximum level
levels - a list of comma-separated level names
level - a single level

minlevel="Debug" is equivalent to levels="Debug,Info,Warn,Error,Fatal"
maxlevel="Info" is equivalent to levels="Trace,Debug,Info"
minlevel="Debug" maxlevel="Warn" is equivalent to levels="Debug,Info,Warn"

Jarek

----- Original Message -----
From: "Glenn E. Lanier, II" <[hidden email]>
To: "'Jaroslaw Kowalski'" <[hidden email]>;
<[hidden email]>
Sent: Saturday, February 18, 2006 10:45 PM
Subject: RE: [Nlog-list] Config file problem


> Jarek,
>
> Just installed the latest version, updated references, and bombed again
> (after checking to make sure my writeTo was correct).
>
> --- NLog XmlLoggingConfiguration Exception ---
> System.ArgumentException: Unknown log level: *
>   at NLog.LogLevel.FromString(String s)
>   at
> NLog.Config.XmlLoggingConfiguration.ConfigureRulesFromElement(LoggingConfigu
> ration config, LoggingRuleCollection rules, XmlElement element)
>   at
> NLog.Config.XmlLoggingConfiguration.ConfigureFromXmlElement(XmlElement
> configElement, String baseDirectory)
>   at NLog.Config.XmlLoggingConfiguration.ConfigureFromFile(String
> fileName)
>   at NLog.Config.XmlLoggingConfiguration..ctor(String fileName)
>   at TBTests.formMain.Main() in c:\glenn\lanier
> consulting\compucom-1\uab-employee
> health\tbtest-c#\tbtests\formmain.cs:line
> 162
>
> Sure enough, my <rules> contained
>
>   <logger name="*" levels="*" writeTo="Console, GenLog" />
>
> instead of
>
>   <logger name="*" levels="Info,Warn,Error,Debug,Fatal,Trace"
> writeTo="Console, GenLog" />
>
> I saw that I could use * for the name, so I _incorrectly_ *assumed* that I
> could also use it for the levels.
>
> As soon as I made the change and tried again, it worked. Sorry for making
> such a stupid mistake public! Thanks for your help.
>
> --G
>
>
>> -----Original Message-----
>> From: Jaroslaw Kowalski [mailto:[hidden email]]
>> Sent: Saturday, February 18, 2006 3:26 PM
>> To: Glenn E. Lanier, II; [hidden email]
>> Subject: Re: [Nlog-list] Config file problem
>>
>> Hi Glenn,
>>
>> 1. Most likely you have a reference to a not-existing target
>> in your <logger
>> /> (somewhere in "appendTo" / "writeTo" attribute)
>> 2. Newer versions of NLog have a check for this condition
>> added and produce
>> a readable error message.
>>
>> Please upgrade to the latest published shapshot (preferably from
>> http://www.nlog-project.org/snapshots/ as this will be the
>> base of the
>> upcoming 0.95 release) and see if this behavior is fixed.
>>
>> Jarek
>>
>> ----- Original Message -----
>> From: "Glenn E. Lanier, II" <[hidden email]>
>> To: "'Jaroslaw Kowalski'" <[hidden email]>;
>> <[hidden email]>
>> Sent: Saturday, February 18, 2006 10:14 PM
>> Subject: RE: [Nlog-list] Config file problem
>>
>>
>> > Jarek,
>> >
>> > Sure. I get this exception/stack trace
>> >
>> > --- NLog XmlLoggingConfiguration Exception ---
>> > System.ArgumentNullException: Value cannot be null.
>> > Parameter name: value
>> >   at System.Collections.CollectionBase.OnValidate(Object value)
>> >   at
>> System.Collections.CollectionBase.System.Collections.IList.Add(Object
>> > value)
>> >   at NLog.TargetCollection.Add(Target value)
>> >   at
>> >
>> NLog.Config.XmlLoggingConfiguration.ConfigureRulesFromElement(
>> LoggingConfigu
>> > ration config, LoggingRuleCollection rules, XmlElement element)
>> >   at
>> >
>> NLog.Config.XmlLoggingConfiguration.ConfigureFromXmlElement(XmlElement
>> > configElement, String baseDirectory)
>> >   at NLog.Config.XmlLoggingConfiguration.ConfigureFromFile(String
>> > fileName)
>> >   at NLog.Config.XmlLoggingConfiguration..ctor(String fileName)
>> >   at TBTests.formMain.Main() in c:\glenn\lanier
>> > consulting\compucom-1\uab-employee
>> > health\tbtest-c#\tbtests\formmain.cs:line
>> > 162
>> >
>> > generated by the following code:
>> >
>> > string sFile = "TBTests.logging.config";
>> > FileInfo fi = new FileInfo(sFile);
>> > if (!fi.Exists)
>> > {
>> > MessageBox.Show(string.Format("Unable to
>> > find required file {0}", sFile), "Configuration Error",
>> > MessageBoxButtons.OK, MessageBoxIcon.Error);
>> > return;
>> > }
>> >
>> > try
>> > {
>> > NLog.Config.XmlLoggingConfiguration xlc =
>> > null;
>> > xlc = new
>> > NLog.Config.XmlLoggingConfiguration(sFile);
>> > LogManager.Configuration = xlc;
>> > }
>> > catch (Exception ex)
>> > {
>> > Console.WriteLine("\n--- NLog
>> > XmlLoggingConfiguration Exception ---\n{0}\n", ex.ToString());
>> > }
>> >
>> > which is the exact same procedure I've used in the past in
>> other projects
>> > (I
>> > simply copied the code). The only difference (that I can
>> tell) is this is
>> > occurring after I re-installed Windows/VS2003/NLog 0.9.
>> >
>> > --G
>> >
>> >> -----Original Message-----
>> >> From: [hidden email]
>> >> [mailto:[hidden email]] On Behalf Of
>> >> Jaroslaw Kowalski
>> >> Sent: Saturday, February 18, 2006 10:42 AM
>> >> To: Glenn E. Lanier, II; [hidden email]
>> >> Subject: Re: [Nlog-list] Config file problem
>> >>
>> >> Can you send the entire exception, along with the stack
>> >> trace? My initial
>> >> idea is that you're passing the wrong path.
>> >>
>> >> Jarek
>> >> ----- Original Message -----
>> >> From: "Glenn E. Lanier, II" <[hidden email]>
>> >> To: <[hidden email]>
>> >> Sent: Friday, February 17, 2006 4:00 PM
>> >> Subject: [Nlog-list] Config file problem
>> >>
>> >>
>> >> >I just re-built my system, so I probably missed putting
>> >> something back that
>> >> > is causing this error.
>> >> >
>> >> > When I try to load the XmlLoggingConfiguration, I get a
>> >> > System.ArgumentNullException in mscorlib.dll on the new
>> >> > Nlog.Config.XmlLoggingCOnfiguration line.
>> >> >
>> >> > Error>(An unhandled exception of type
>> 'System.ArgumentNullException'
>> >> > occurred in mscorlib.dll
>> >> > Error>Additional information: Value cannot be null.)
>> >> >
>> >> > I created a new C# Windows application (using VS 2003). In
>> >> Main(), I am
>> >> > trying to initialize my logger object using the code below.
>> >> I know sFile
>> >> > exists, because I check beforehand.
>> >> >
>> >> > Code>NLog.Config.XmlLoggingConfiguration xlc = new
>> >> > NLog.Config.XmlLoggingConfiguration(sFile);
>> >> > Code>LogManager.Configuration = xlc;
>> >> > Code>logger.Info("TB Tests Database program starting");
>> >> >
>> >> > Elsewhere, I have:
>> >> >
>> >> > Code>static Logger logger = LogManager.GetLogger("formMain");
>> >> >
>> >> > (not that it matters at this point).
>> >> >
>> >> >
>> >> > Complete contents of log.config are:
>> >> > ------ log.config begin ------
>> >> > <configuration>
>> >> >   <configSections>
>> >> >      <section name="nlog"
>> >> type="NLog.Config.ConfigSectionhandler, NLog" />
>> >> >   </configSections>
>> >> >   <nlog autoReload="true">
>> >> >      <targets>
>> >> >         <target name="console" type="Console"
>> >> >
>> >> layout="${longdate}|${machinename}|${windows-identity}|${level
>> > :uppercase=tru
>> >> > e}|${logger}|${message}" />
>> >> >         <target name="AuditLog" type="File"
>> >> > filename="${basedir}/logs/aud/${date:format=yyyy.MM}-Audit.log"
>> >> > CreateDirs="true"
>> >> >
>> >> layout="${longdate}|${machinename}|${windows-identity}|${level
>> > :uppercase=tru
>> >> > e}|${logger}|${message}" />
>> >> >         <target name="GenLog" type="File"
>> >> >
>> filename="${basedir}/logs/gen/${date:format=yyyy.MM.dd}-General.log"
>> >> > CreateDirs="true"
>> >> >
>> >> layout="${longdate}|${machinename}|${windows-identity}|${level
>> > :uppercase=tru
>> >> > e}|${logger}|${message}|${callsite}" />
>> >> >         <target name="ErrorLog" type="File"
>> >> >
>> >> filename="${basedir}/logs/err/${date:format=yyyy.MM}-MonthlyEr
>> > rors.log"
>> >> > CreateDirs="true"
>> >> >
>> >> layout="${longdate}|${machinename}|${windows-identity}|${level
>> > :uppercase=tru
>> >> > e}|${logger}|${message}|${callsite}" />
>> >> >         <target name="viewer" type="NLogViewer"
>> >> > address="udp://localhost:4000" />
>> >> >      </targets>
>> >> >      <rules>
>> >> >         <logger name="*" levels="Error,Fatal"
>> writeTo="ErrorLog" />
>> >> >         <logger name="Import"
>> levels="Info,Warn,Error,Debug,Fatal"
>> >> > writeTo="GenLog" final="true" />
>> >> >         <logger name="Audit" levels="Info,Warn,Error,Debug,Fatal"
>> >> > writeTo="AuditLog" />
>> >> >         <logger name="*"
>> levels="Info,Warn,Error,Debug,Fatal,Trace"
>> >> > writeTo="Console, GenLog" />
>> >> >      </rules>
>> >> >   </nlog>
>> >> > </configuration>
>> >> > ------ log.config end -------
>> >> >
>> >> > Any help would be greatly appreciated.
>> >> >
>> >> > Thanks.
>> >> >
>> >> > --G
>> >> >
>> >> >
>> >> >
>> >> > -------------------------------------------------------
>> >> > This SF.net email is sponsored by: Splunk Inc. Do you grep
>> >> through log
>> >> > files
>> >> > for problems?  Stop!  Download the new AJAX search
>> engine that makes
>> >> > searching your log files as easy as surfing the  web.
>> >> DOWNLOAD SPLUNK!
>> >> >
>> >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&
>> > dat=121642
>> >> > _______________________________________________
>> >> > Nlog-list mailing list
>> >> > [hidden email]
>> >> > https://lists.sourceforge.net/lists/listinfo/nlog-list
>> >> >
>> >>
>> >>
>> >>
>> >> -------------------------------------------------------
>> >> This SF.net email is sponsored by: Splunk Inc. Do you grep
>> >> through log files
>> >> for problems?  Stop!  Download the new AJAX search engine
>> that makes
>> >> searching your log files as easy as surfing the  web.
>> >> DOWNLOAD SPLUNK!
>> >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&
>> > dat=121642
>> >> _______________________________________________
>> >> Nlog-list mailing list
>> >> [hidden email]
>> >> https://lists.sourceforge.net/lists/listinfo/nlog-list
>> >>
>> >
>> >
>> >
>> > -------------------------------------------------------
>> > This SF.net email is sponsored by: Splunk Inc. Do you grep
>> through log
>> > files
>> > for problems?  Stop!  Download the new AJAX search engine that makes
>> > searching your log files as easy as surfing the  web.
>> DOWNLOAD SPLUNK!
>> >
>> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&
> dat=121642
>> > _______________________________________________
>> > Nlog-list mailing list
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/nlog-list
>> >
>>
>>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through log
> files
> for problems?  Stop!  Download the new AJAX search engine that makes
> searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
> _______________________________________________
> Nlog-list mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/nlog-list
>



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Nlog-list mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/nlog-list
NLog Blog