How to log a log through log4net when using the Task Scheduler to start a console application?

Asked

Viewed 82 times

0

I compiled a console application in c# that has log4net (which is already working normally when I run the app) and configured through Windows Task Scheduler to run the application console every day x hours.

But when it runs the program, the output of the log is not being done, it simply doesn’t log in. I would like to know how to log him even programmed to automatically run in Ask Scheduler, follow my log4net.config:

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

  <root>
    <level value="ALL" />
    <appender-ref ref="console" />
    <appender-ref ref="file" />
  </root>

  <appender name="console" type="log4net.Appender.ConsoleAppender">
    <layout type="log4net.Layout.PatternLayout">
      <!--<conversionPattern value="%date %level %logger - %message%newline" />-->
      <conversionPattern value="%message%newline" />
    </layout>
  </appender>

  <appender name="file" type="log4net.Appender.RollingFileAppender">
    <file value="logs/migracaoLog.txt" />
    <appendToFile value="false" />
    <rollingStyle value="Size" />
    <maxSizeRollBackups value="5" />
    <maximumFileSize value="10MB" />
    <staticLogFileName value="true" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date [%thread] %level %logger - %message%newline" />
    </layout>
  </appender>  
</log4net>

</configuration>
  • this is the application configuration file?

  • No, this is log4net.config is log4net’s configuration file

  • got it, are you sure it can’t be permission problem? the user who is setting to runs the application has write permission in the folder?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.