I have a solution (in .NET Framework 4.7.2) that contains 2 projects, each of those contains Main() and is run independently. I have created a Logger for each of them, and the messages from each being recorded fine in the Console or the Azure Log. But only messages from one process are getting sent to the Loggly. And I have CloseAndFlush in each of them.
And when I debug any of those projects individually (locally) they would send the message to Loggly.
Any thoughts on what could be wrong here, and how to make messages from both processes be sent to Loggly?
Project Job1:
{
public class Program
{
public static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration().ReadFrom.AppSettings().CreateLogger();
Log.Information("Job1 Starting...");
Log.Information("2nd line ..");
Log.Information("third line ..");
Serilog.Debugging.SelfLog.Enable(msg => Console.WriteLine(msg));
Console.WriteLine("Job1 Starting...");
try
{
Install();
while (!IsExists)
{
Execute();
Thread.Sleep(1000);
}
}
finally
{
Log.CloseAndFlush();
}
}
public static void Execute()
{
Log.Information("Executing Job1 ...");
... some code here ...
}
}
}
Project Job2:
{
public class Program
{
public static void Main(string[] args)
{
Log.Logger = new LoggerConfiguration().ReadFrom.AppSettings().CreateLogger();
Log.Information("Job2 Starting...");
Serilog.Debugging.SelfLog.Enable(msg => Console.WriteLine(msg));
Console.WriteLine("Job2 Starting...");
try
{
Install();
var task = Execute();
task.Wait();
}
finally
{
Log.CloseAndFlush();
}
}
public static async Task Execute()
{
Log.Information("Executing Job2 ...");
... some code here ...
}
}
}
App.config for Job1:
<appSettings>
<add key="serilog:minimum-level" value="Debug" />
<add key="serilog:using:Loggly" value="Serilog.Sinks.Loggly" />
<add key="serilog:write-to:Loggly" />
<add key="Loggly.ApplicationName" value="myapp" />
<add key="Loggly.CustomerToken" value="MyTokenXXX" />
<add key="Loggly.Tags" value="myapp,job1" />
</appSettings>
App.config for Job2:
<appSettings>
<add key="serilog:minimum-level" value="Debug" />
<add key="serilog:using:Loggly" value="Serilog.Sinks.Loggly" />
<add key="serilog:write-to:Loggly" />
<add key="Loggly.ApplicationName" value="myapp" />
<add key="Loggly.CustomerToken" value="MyTokenXXX" />
<add key="Loggly.Tags" value="myapp,job2" />
</appSettings>
NuGet packages installed for both projects:
- Serilog v2.10.0
- Serilog.Extensions.Logging v3.0.1
- Serilog.Settings.AppSettings v2.2.2
- Serilog.Settings.Configuration v3.3.0
- Serilog.Sinks.File v4.1.0
- Serilog.Sinks.Loggly v5.4.0
- Serilog.Sinks.PeriodicBatching v2.3.0
- Serilog.Sinks.RollingFile v3.3.0