You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4net-user@logging.apache.org by DeveloperM <mf...@netzero.com> on 2015/04/07 15:44:19 UTC
Logging works in VS but not when deployed
(Apologizing for cross-posting...)
I am working in a Dynamics CRM 2011on-premises C# .Net environment. This is
the first time I have used log4net so bear with me, please...
My app.config entry for log4net is:
<log4net>
<appender name="RollingFileAppender"
type="log4net.Appender.RollingFileAppender">
<file value="EDI File Generator Log.txt" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="20MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %level %logger -
%message%newline" />
</layout>
</appender>
<root>
<level value="INFO"/>
<appender-ref ref="RollingFileAppender"/>
</root>
In the program I have coded:
private static readonly ILog log =
LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
And throughout the program there are several places I call a method which
executes:
log.Info(sMessage);
When I execute the code from VS 2010, the program runs and messages are
logged to the log file. When I deployed the program to my own machine, the
program runs but no log entries are written.
--
View this message in context: http://apache-logging.6191.n7.nabble.com/Logging-works-in-VS-but-not-when-deployed-tp54506.html
Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Logging works in VS but not when deployed
Posted by DeveloperM <mf...@netzero.com>.
Joseph, thanks for the clue. You were right: the Configurator was looking for
"app.config" and not the deployed config file name.
--
View this message in context: http://apache-logging.6191.n7.nabble.com/Logging-works-in-VS-but-not-when-deployed-tp54506p54519.html
Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Logging works in VS but not when deployed
Posted by DeveloperM <mf...@netzero.com>.
The solution was to move the [assembly: log4net.Config.XmlConfigurator]
declarative to the AssemblyInfo.cs file and to not point to any particular
config file.
Thanks to all who responded....
--
View this message in context: http://apache-logging.6191.n7.nabble.com/Logging-works-in-VS-but-not-when-deployed-tp54506p54518.html
Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Logging works in VS but not when deployed
Posted by Pascal ROZE <pa...@gmail.com>.
Does the file exist here: C:\Program Files (x86)\CE\MyProgram\app.config
????
On 7 April 2015 at 20:56, DeveloperM <mf...@netzero.com> wrote:
> Ok, why is it found when run in the IDE (VS 2010) but not when deployed?
> And
> what needs to be done to correct this?
>
>
>
> --
> View this message in context:
> http://apache-logging.6191.n7.nabble.com/Logging-works-in-VS-but-not-when-deployed-tp54506p54516.html
> Sent from the Log4net - Users mailing list archive at Nabble.com.
>
Re: Logging works in VS but not when deployed
Posted by DeveloperM <mf...@netzero.com>.
Ok, why is it found when run in the IDE (VS 2010) but not when deployed? And
what needs to be done to correct this?
--
View this message in context: http://apache-logging.6191.n7.nabble.com/Logging-works-in-VS-but-not-when-deployed-tp54506p54516.html
Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Logging works in VS but not when deployed
Posted by Pascal ROZE <pa...@gmail.com>.
log4net: config file [C:\Program Files (x86)\CE\MyProgram\app.config]
not found
The config file was NOT found
On 7 April 2015 at 20:47, DeveloperM <mf...@netzero.com> wrote:
> Thanks for the suggestion, Pascal. I did that and this is what was written
> to
> the Console:
>
> log4net: log4net assembly [log4net, Version=1.2.13.0, Culture=neutral,
> PublicKey
> Token=669e0ddf0bb1aa2a]. Loaded from [C:\Program Files
> (x86)\CE\CRMEDIFileGenera
> tor\log4net.dll]. (.NET Runtime [4.0.30319.18444] on Microsoft Windows NT
> 6.1.76
> 01 Service Pack 1)
> log4net: defaultRepositoryType [log4net.Repository.Hierarchy.Hierarchy]
> log4net: Creating repository for assembly [MyProgram, Version=1.0.0.0,
> Culture=neutral, PublicKeyToken=null]
> log4net: Assembly [MyProgram, Version=1.0.0.0, Culture=neutral, Public
> KeyToken=null] Loaded From [C:\Program Files (x86)\CE\MyProgram\CRMEDI
> FileGenerator.exe]
> log4net: Assembly [MyProgram, Version=1.0.0.0, Culture=neutral, Public
> KeyToken=null] does not have a RepositoryAttribute specified.
> log4net: Assembly [MyProgram, Version=1.0.0.0, Culture=neutral, Public
> KeyToken=null] using repository [log4net-default-repository] and repository
> type
> [log4net.Repository.Hierarchy.Hierarchy]
> log4net: Creating repository [log4net-default-repository] using type
> [log4net.Re
> pository.Hierarchy.Hierarchy]
> log4net: configuring repository [log4net-default-repository] using file
> [C:\Prog
> ram Files (x86)\CE\MyProgram\app.config] watching for file updates
> log4net: configuring repository [log4net-default-repository] using file
> [C:\Prog
> ram Files (x86)\CE\MyProgram\app.config]
> log4net: config file [C:\Program Files (x86)\CE\MyProgram\app.config]
> not found. Configuration unchanged.
>
>
> Can you help me interpret this? Certainly the app.config file was found;
> the correct CRM db connection is made and data is correctly returned from
> the instance I set in that config file.
>
>
>
>
> --
> View this message in context:
> http://apache-logging.6191.n7.nabble.com/Logging-works-in-VS-but-not-when-deployed-tp54506p54514.html
> Sent from the Log4net - Users mailing list archive at Nabble.com.
>
Re: Logging works in VS but not when deployed
Posted by DeveloperM <mf...@netzero.com>.
Thanks for the suggestion, Pascal. I did that and this is what was written to
the Console:
log4net: log4net assembly [log4net, Version=1.2.13.0, Culture=neutral,
PublicKey
Token=669e0ddf0bb1aa2a]. Loaded from [C:\Program Files
(x86)\CE\CRMEDIFileGenera
tor\log4net.dll]. (.NET Runtime [4.0.30319.18444] on Microsoft Windows NT
6.1.76
01 Service Pack 1)
log4net: defaultRepositoryType [log4net.Repository.Hierarchy.Hierarchy]
log4net: Creating repository for assembly [MyProgram, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null]
log4net: Assembly [MyProgram, Version=1.0.0.0, Culture=neutral, Public
KeyToken=null] Loaded From [C:\Program Files (x86)\CE\MyProgram\CRMEDI
FileGenerator.exe]
log4net: Assembly [MyProgram, Version=1.0.0.0, Culture=neutral, Public
KeyToken=null] does not have a RepositoryAttribute specified.
log4net: Assembly [MyProgram, Version=1.0.0.0, Culture=neutral, Public
KeyToken=null] using repository [log4net-default-repository] and repository
type
[log4net.Repository.Hierarchy.Hierarchy]
log4net: Creating repository [log4net-default-repository] using type
[log4net.Re
pository.Hierarchy.Hierarchy]
log4net: configuring repository [log4net-default-repository] using file
[C:\Prog
ram Files (x86)\CE\MyProgram\app.config] watching for file updates
log4net: configuring repository [log4net-default-repository] using file
[C:\Prog
ram Files (x86)\CE\MyProgram\app.config]
log4net: config file [C:\Program Files (x86)\CE\MyProgram\app.config]
not found. Configuration unchanged.
Can you help me interpret this? Certainly the app.config file was found;
the correct CRM db connection is made and data is correctly returned from
the instance I set in that config file.
--
View this message in context: http://apache-logging.6191.n7.nabble.com/Logging-works-in-VS-but-not-when-deployed-tp54506p54514.html
Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Logging works in VS but not when deployed
Posted by Pascal ROZE <pa...@gmail.com>.
Hello
Enable the log4net internal debug to get more info.
Cheers
On 7 April 2015 at 19:21, DeveloperM <mf...@netzero.com> wrote:
> Thanks for responding. The log4net reference *Copy Local* property is
> marked
> True.
>
>
>
> --
> View this message in context:
> http://apache-logging.6191.n7.nabble.com/Logging-works-in-VS-but-not-when-deployed-tp54506p54512.html
> Sent from the Log4net - Users mailing list archive at Nabble.com.
>
Re: Logging works in VS but not when deployed
Posted by DeveloperM <mf...@netzero.com>.
Thanks for responding. The log4net reference *Copy Local* property is marked
True.
--
View this message in context: http://apache-logging.6191.n7.nabble.com/Logging-works-in-VS-but-not-when-deployed-tp54506p54512.html
Sent from the Log4net - Users mailing list archive at Nabble.com.
Re: Logging works in VS but not when deployed
Posted by "Joseph L. Casale" <jc...@activenetwerx.com>.
> When I execute the code from VS 2010, the program runs and messages are
> logged to the log file. When I deployed the program to my own machine, the
> program runs but no log entries are written.
When you deploy, does the log4net assembly go with it as well as the app.config
with your logging configuration (renamed to match your binary)?
jlc