10.2.0, Angular
Please, also see log4net stopped generating the logs.
I think there is an issue with logging configuration!? Since ASPNETZERO 10.0.0 logging stopped to work in debug environment but was still working in production environment. Since ASPNETZERO 10.2.0 logging is working in debug environment but stopped to work in production environment.
ASPNETZERO-Team, please confirm if there is a problem.
15 Answer(s)
-
0
In my production environment I just changed
log4net.config
from<file value="../../../App_Data/Logs/Logs.txt" />
to<file value="App_Data/Logs/Logs.txt" />
and recycled the application pool on IIS. Now logging is working as expected again.I think production environment should use
log4net.Production.config
, right? -
0
Hi @alexanderpilhar
Yes, you are right. for Production, log4net.Production.config must be used. As I can see, latest version has this code block https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Public/Startup/Startup.cs#L73. Could you compare it with your project ?
-
0
-
0
The only thing I can see is the following:
~~In the Code above the file is named
log4net.Production.config
but actual file name islog4net.production.config
(P vs p). Could this be the problem?~~ *EDIT Hm, when published file name is
log4net.Production.config
again (with P).EDIT * I was wrong about this: actual file name is
log4net.Production.config
, I confused it withappsettings.production.config
.... -
0
Hi,
In that case, I think
log4net.Production.config
will be used but maybe the path in log4net.Production.config is wrong. Could that be the reason ? -
0
Path in
log4net.Production.config
ist correct/working (<file value="App_Data/Logs/Logs.txt" />
). But it doesn't matter as it is not what is being used (log4net.config
is used instead). -
0
Hi @alexanderpilhar
As you both mentioned there are two config file. log4net.config: For development environment log4net.Production.config: For production environment,
When you debug your code, logs will be written to
aspnet-core\src\[YOURAPPNAME].Web.Host\App_Data\Logs\Logs.txt
As set here: https://github.com/aspnetzero/aspnet-zero-core/blob/f0acf27b6151e2993af2abbc647968f1f578f91f/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Host/log4net.config#L4When you publish your code, logs will be written to
[YOURPUBLISHFOLDER]\App_Data\Logs\Logs.txt
As set here: https://github.com/aspnetzero/aspnet-zero-core/blob/f0acf27b6151e2993af2abbc647968f1f578f91f/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Host/log4net.Production.config#L4Is it not working as expected on your app?
-
0
Hi @musa.demir
Yes, that is what i was expecting.
But it turns out both my environments (dev and prod) use
log4net.config
instead of production environment usinglog4net.Production.config
.BTW, this is also true vor
appsettings.json
(used by dev and prod) instead ofappsettings.production.json
being used for production environment. -
0
Hi @alexanderpilhar
Could you log somewhere to see if your app's environment is set to Production ?
-
0
Build configuration is set to
Release
in my publishing-profile.@ismcagdas, sorry, but I don't understand what you want me to do - what do you mean with 'could you log somewhere' !?
-
0
Hi,
For example, you can get this infor in a controller like this https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Host/Controllers/HomeController.cs#L26 and Log it using the Logger.
-
0
Hi @ismcagdas,
I managed to log the environment as requested and it says 'Development'. Do I miss some configuration?
-
0
Hi @alexanderpilhar
Sorry for my late reply. Could you share how do you deploy your app ? It might be related to that. You can set environment variable on the deployed server to easily fix this.
-
0
Hm ... I checked system variables on server and found out that
ASPNETCORE_ENVIRONMENT
is set toDevelopment
globally.Also see: Use multiple environments in ASP.NET Core / Set environment on Windows
I'll have to contact our sys admin to check whether this is on purpose.
-
0
Yes, after removing the system variable and restarting the server everything is working as expected - thanks for helping me to figure this out!