public class Program
{
private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
static void Main()
{
log4net.Config.XmlConfigurator.Configure();
try
{
MainA().Wait();
}
catch (Exception ex)
{
Log.ErrorFormat("Failed to Delete Data, Error: {0}, Stack Trace {1}, Inner Exception {2}", ex.Message, ex.StackTrace, ex.InnerException);
}
}
public static async Task MainA()
{
Log.InfoFormat("Service started at {0}", DateTime.UtcNow);
WebJobService srv = new WebJobService();
await srv.DeleteData();
Log.InfoFormat("Service ended at {0}", DateTime.UtcNow);
}
}
App.Config
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
Please check above code. It write logs only once when we do deployment on server after that it did not write any logs in MyLogs.txt file.