Roman Meisl | 8 Jul 2009 15:49
Picon

Checking configuration file for syntax errors?

Hello,

I wonder if there's a way to check the syntax of an XML configuration file. I'm aware of the
Repository.Configured-property but I'd like to check the configuration file before applying it.

Background:
When using the XmlConfiguratorAttribute I want to utilize a static method which checks the denoted file.
If the file is eroneous the method will return the path to a fallback config file which is existing and working.

TIA,

   Roman
--

-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01

Stephen Murtagh | 8 Jul 2009 17:02
Picon
Favicon

AUTO: Stephen Murtagh is out of the office. (returning 06/07/2009)


I will be out of the office starting Thu 06/25/2009 and will not return
until Fri 07/10/2009.

I will respond to your message when I return.

If you are experiencing a problem that requires urgent assistance please
contact the IT Service Desk (6634).

Note: This is an automated response to your message  "Checking
configuration file for syntax errors?" sent on 08/07/2009 14:49:06.

This is the only notification you will receive while this person is away.

*********************************************************************************
Disclaimer: This electronic mail, together with any attachments, is for the exclusive and confidential
use of the recipient addressee. Any other distribution, use or reproduction without our prior consent is
unauthorised and strictly prohibited. If you have received this message in error, please delete it
immediately and contact the sender directly or the Robert Wiseman & Sons Ltd IT Helpdesk on +44 (0)1355
270634. Any views or opinions expressed in this message are those of the author and do not necessarily
represent those of Robert Wiseman & Sons Ltd or of any of its associated companies. No reliance may be
placed on this message without written confirmation from an authorised representative of the company.

Robert Wiseman & Sons Limited reserves the right to monitor all e-mail communications through its network.

This message has been checked for viruses but the recipient is strongly advised to re-scan the message
before opening any attachments or attached executable files.

ROBERT WISEMAN & SONS LIMITED
Registered Number: 87376 Scotland
(Continue reading)

Alexander | 14 Jul 2009 08:00
Picon

Re: RollingFileAppender destination failure.

Hello user list,

couldn't find an answer to this type of problem.
what is the best approach to reroute logs from rollingfileappender to
another one if it's destination becomes unreachable?

--
Sincerely,
Alexander N.

MFranz | 15 Jul 2009 22:36

log4net within Excel RTD/UDF


Hi,

I am using C# to write an Excel RTD (real-time data) and UDF (user defined function) and having trouble figuring out how I can get log4net to configure itself.  My understanding is that it uses the AppDomain.CurrentDomain.BaseDirectory to look for the configuration file.  This is the Excel installation directory.  I however do not install my application into that directory and do not put any configuration there.  My code is installed into its' own directory which can be found by using Assembly.GetExecutingAssembly().CodeBase within my code.  Is there an easy way to have log4net use a different directory when searching for the configuration file?

I have had success manually loading the configuration, but this forces me to put my loading logic into all of the potential entry points.  I can have multiple RTDs and UDFs defined within one assembly.  So I am looking for an easy way to have one place to worry about the configuration loading.

thanks

Michael


*******************************************************************************
This e-mail message is intended solely for the use of the addressee.
The message may contain information that is privileged and
confidential.
Disclosure to anyone other than the intended recipient is prohibited.
If you are not the intended recipient, please do not disseminate,
distribute or copy this communication, by e-mail or otherwise. Instead,
please notify us immediately by return e-mail(including the original
message with your reply) and then delete and discard all copies of the
message. We have taken precautions to minimize the risk of transmitting
software viruses but nevertheless advise you to carry out your own
virus checks on any attachment to this message. We accept
no liability for any loss or damage caused by software viruses.
*******************************************************************************

 

Brian Browning | 15 Jul 2009 23:04
Picon

Re: log4net within Excel RTD/UDF

Hi Michael,

I believe the easiest way to do that is to to call XmlConfigurator.Configure with the FileInfo object for your desired file.
Is that what you meant when you said you were manually loading the configuration?
If so, I apologize but I think that may be the best you can do.


On Wed, Jul 15, 2009 at 3:36 PM, <MFranz <at> fftw.com> wrote:

Hi,

I am using C# to write an Excel RTD (real-time data) and UDF (user defined function) and having trouble figuring out how I can get log4net to configure itself.  My understanding is that it uses the AppDomain.CurrentDomain.BaseDirectory to look for the configuration file.  This is the Excel installation directory.  I however do not install my application into that directory and do not put any configuration there.  My code is installed into its' own directory which can be found by using Assembly.GetExecutingAssembly().CodeBase within my code.  Is there an easy way to have log4net use a different directory when searching for the configuration file?

I have had success manually loading the configuration, but this forces me to put my loading logic into all of the potential entry points.  I can have multiple RTDs and UDFs defined within one assembly.  So I am looking for an easy way to have one place to worry about the configuration loading.

thanks

Michael


*******************************************************************************
This e-mail message is intended solely for the use of the addressee.
The message may contain information that is privileged and
confidential.
Disclosure to anyone other than the intended recipient is prohibited.
If you are not the intended recipient, please do not disseminate,
distribute or copy this communication, by e-mail or otherwise. Instead,
please notify us immediately by return e-mail(including the original
message with your reply) and then delete and discard all copies of the
message. We have taken precautions to minimize the risk of transmitting
software viruses but nevertheless advise you to carry out your own
virus checks on any attachment to this message. We accept
no liability for any loss or damage caused by software viruses.
*******************************************************************************

 


MFranz | 15 Jul 2009 23:16

Re: log4net within Excel RTD/UDF


Brian,

Yes, that is what I meant by manually.

I have not looked at log4net code, but I wonder if the attribute can be enhanced to use the different base directories.

Thanks for looking.

Michael


Brian Browning <bwbrowning <at> gmail.com>

07/15/2009 05:04 PM

Please respond to
"Log4NET User" <log4net-user <at> logging.apache.org>

To
Log4NET User <log4net-user <at> logging.apache.org>
cc
Subject
Re: log4net within Excel RTD/UDF




Hi Michael,

I believe the easiest way to do that is to to call XmlConfigurator.Configure with the FileInfo object for your desired file.
Is that what you meant when you said you were manually loading the configuration?
If so, I apologize but I think that may be the best you can do.


On Wed, Jul 15, 2009 at 3:36 PM, <MFranz <at> fftw.com> wrote:

Hi,

I am using C# to write an Excel RTD (real-time data) and UDF (user defined function) and having trouble figuring out how I can get log4net to configure itself.  My understanding is that it uses the AppDomain.CurrentDomain.BaseDirectory to look for the configuration file.  This is the Excel installation directory.  I however do not install my application into that directory and do not put any configuration there.  My code is installed into its' own directory which can be found by using Assembly.GetExecutingAssembly().CodeBase within my code.  Is there an easy way to have log4net use a different directory when searching for the configuration file?

I have had success manually loading the configuration, but this forces me to put my loading logic into all of the potential entry points.  I can have multiple RTDs and UDFs defined within one assembly.  So I am looking for an easy way to have one place to worry about the configuration loading.

thanks

Michael


*******************************************************************************
This e-mail message is intended solely for the use of the addressee.
The message may contain information that is privileged and
confidential.
Disclosure to anyone other than the intended recipient is prohibited.
If you are not the intended recipient, please do not disseminate,
distribute or copy this communication, by e-mail or otherwise. Instead,
please notify us immediately by return e-mail(including the original
message with your reply) and then delete and discard all copies of the
message. We have taken precautions to minimize the risk of transmitting
software viruses but nevertheless advise you to carry out your own
virus checks on any attachment to this message. We accept
no liability for any loss or damage caused by software viruses.
*******************************************************************************

 

Dahl, Scott (CMA Consulting | 16 Jul 2009 20:42

Failed to find config section - Only after Environment.Exit()

I have a .net application using log4net that works fine up until the application exits using Environment.Exit().  At that point I get the following error message:

“log4net:ERROR XmlConfigurator: Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the <log4net> and <configSections> elements. The configuration section should look like: <section name="log4net"

type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />”

 

The log file is created and entries are written fine when the app runs.  I’ve tried doing a logmanager.shudown() prior to the Environment.Exit() but that doesn’t seem to help either.  The issue is more of an annoyance than anything else as the logging works as expected.  The app is running at a client site though and they want to know why they’re seeing this error in their scheduler.

 

Here’s the log4net entries in my app.config.

 

<?xml version="1.0" encoding="utf-8"?>

<configuration>

  <configSections>

    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

      <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler" />

    </sectionGroup>

  </configSections>

 

    <!-- This section contains the log4net configuration settings -->

    <log4net>

      <!-- Define some output appenders -->

      <appender name="LogFileAppender" type="log4net.Appender.FileAppender">

        <file value=".\\GenericInterfaceClient.log" />

        <appendToFile value="true" />

        <layout type="log4net.Layout.PatternLayout">

          <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />

        </layout>

      </appender>

      <logger name="default">

        <level value="ALL" />

        <appender-ref ref="LogFileAppender" />

      </logger>

    </log4net>

  </applicationSettings>

</configuration>

 

Any ideas?

 

Brian Browning | 16 Jul 2009 21:46
Picon

Re: Failed to find config section - Only after Environment.Exit()

When I tried your app.config I received an exception immediately upon calling XmlConfigurator.Configure();
I had to move some things around in it for it to work:
There doesn't seem to be an exception when I call Environment.Exit(1); either.
Does modifying your app.config like below solve your problem?

<?xml version="1.0" encoding="utf-8" ?>

<configuration>
    <configSections>
        <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        </sectionGroup>
    </configSections>

    <applicationSettings>
    <!-- .... -->
    </applicationSettings>
    <log4net>
            <!-- Define some output appenders -->
            <appender name="LogFileAppender" type="log4net.Appender.FileAppender">
                <file value="GenericInterfaceClient.log" />
                <appendToFile value="true" />
                <layout type="log4net.Layout.PatternLayout">
                    <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
                </layout>
            </appender>
            <logger name="default">
              <level value="ALL" />
                <appender-ref ref="LogFileAppender" />
            </logger>
     </log4net>

  
 
</configuration>


On Thu, Jul 16, 2009 at 1:42 PM, Dahl, Scott (CMA Consulting) <sdahl <at> cma.com> wrote:

I have a .net application using log4net that works fine up until the application exits using Environment.Exit().  At that point I get the following error message:

“log4net:ERROR XmlConfigurator: Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the <log4net> and <configSections> elements. The configuration section should look like: <section name="log4net"

type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />”

 

The log file is created and entries are written fine when the app runs.  I’ve tried doing a logmanager.shudown() prior to the Environment.Exit() but that doesn’t seem to help either.  The issue is more of an annoyance than anything else as the logging works as expected.  The app is running at a client site though and they want to know why they’re seeing this error in their scheduler.

 

Here’s the log4net entries in my app.config.

 

<?xml version="1.0" encoding="utf-8"?>

<configuration>

  <configSections>

    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

      <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler" />

    </sectionGroup>

  </configSections>

 

    <!-- This section contains the log4net configuration settings -->

    <log4net>

      <!-- Define some output appenders -->

      <appender name="LogFileAppender" type="log4net.Appender.FileAppender">

        <file value=".\\GenericInterfaceClient.log" />

        <appendToFile value="true" />

        <layout type="log4net.Layout.PatternLayout">

          <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />

        </layout>

      </appender>

      <logger name="default">

        <level value="ALL" />

        <appender-ref ref="LogFileAppender" />

      </logger>

    </log4net>

  </applicationSettings>

</configuration>

 

Any ideas?

 


Sree | 17 Jul 2009 09:08
Picon

RE: Error while sending Mail to smtp.gmail.com

 

 

From: Sree [mailto:sree.optust <at> gmail.com]
Sent: Friday, July 17, 2009 12:30 PM
To: 'log4net-user <at> logging.apache.org'
Subject: Error while sending Mail to smtp.gmail.com

 

à I’m able to successfully send mail using .net code through gmail by enabling SSL.

 

But using log4net its given error:

 

My Code in app.config file:

 

     <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">

      <to value="myusername <at> gmail.com" />

      <from value=" myusername <at> gmail.com " />

      <subject value="test logging message" />

      <smtpHost value="smtp.gmail.com" />

      <authentication value = "Basic" />

      <username value = " myusername <at> gmail.com " />

      <password value = "mypassword" />

      <ssl value ="true"/>

      <port value ="465"/>

      <bufferSize value="512" />

      <lossy value="true" />

      <evaluator type="log4net.Core.LevelEvaluator">

        <threshold value="ALL"/>

      </evaluator>

      <layout type="log4net.Layout.PatternLayout">

        <conversionPattern value="%newline%date [%thread] %-5level %logger [%property{NDC}] - %message%newline%newline%newline" />

      </layout>

    </appender>

 

 

 

Getting error:

 

log4net:ERROR [SmtpAppender] Error occurred while sending e-mail notification.

System.Net.Mail.SmtpException: The operation has timed out.

   at System.Net.Mail.SmtpClient.Send(MailMessage message)

   at log4net.Appender.SmtpAppender.SendEmail(String messageBody)

   at log4net.Appender.SmtpAppender.SendBuffer(LoggingEvent[] events)

 

 

 

I tried using STARTTLS protocol also…which gave me an error with authentication and so….

 

 

 

Please help me out….I deadly need it work it down…

 

Best regards,

Sree

Radovan Raszka | 17 Jul 2009 10:13
Picon
Favicon

RE: Error while sending Mail to smtp.gmail.com

According to documentation, there is no Ssl property for SmtpAppender. According source code it is named EnableSsl, so repair your config.
But I'm not sure if it helps...
Radovan Raszka

From: Sree [mailto:sree.optust <at> gmail.com]
Sent: Friday, July 17, 2009 12:30 PM
To: 'log4net-user <at> logging.apache.org'
Subject: Error while sending Mail to smtp.gmail.com

 

à I’m able to successfully send mail using .net code through gmail by enabling SSL.

 

But using log4net its given error:

 

My Code in app.config file:

 

     <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">

      <to value="myusername <at> gmail.com" />

      <from value=" myusername <at> gmail.com " />

      <subject value="test logging message" />

      <smtpHost value="smtp.gmail.com" />

      <authentication value = "Basic" />

      <username value = " myusername <at> gmail.com " />

      <password value = "mypassword" />

      <ssl value ="true"/>

      <port value ="465"/>

      <bufferSize value="512" />

      <lossy value="true" />

      <evaluator type="log4net.Core.LevelEvaluator">

        <threshold value="ALL"/>

      </evaluator>

      <layout type="log4net.Layout.PatternLayout">

        <conversionPattern value="%newline%date [%thread] %-5level %logger [%property{NDC}] - %message%newline%newline%newline" />

      </layout>

    </appender>

 

 

 

Getting error:

 

log4net:ERROR [SmtpAppender] Error occurred while sending e-mail notification.

System.Net.Mail.SmtpException: The operation has timed out.

   at System.Net.Mail.SmtpClient.Send(MailMessage message)

   at log4net.Appender.SmtpAppender.SendEmail(String messageBody)

   at log4net.Appender.SmtpAppender.SendBuffer(LoggingEvent[] events)

 

 

 

I tried using STARTTLS protocol also…which gave me an error with authentication and so….

 

 

 

Please help me out….I deadly need it work it down…

 

Best regards,

Sree


Gmane