Base solution for your next web application
Open Closed

Logging on Azure platform #10897


User avatar
0
uabel created

Hello. We are running our application on Azure. Unfortunately the logging doesn't work there anymore. We are using e.g. public ILogger Logger { get; set; } Logger.Debug("test") These values are still written to the log: DEBUG 2022-02-15 12:55:27,651 [1 ] Abp.Modules.AbpModuleManager - 13 modules loaded. DEBUG 2022-02-15 12:56:20,096 [1 ] Abp.Localization.LocalizationManager - Initializing 4 localization sources. DEBUG 2022-02-15 12:56:20,127 [1 ] Abp.Localization.LocalizationManager - Initialized localization source: Abp DEBUG 2022-02-15 12:56:20,127 [1 ] Abp.Localization.LocalizationManager - Initialized localization source: AbpWeb DEBUG 2022-02-15 12:56:20,127 [1 ] Abp.Localization.LocalizationManager - Initialized localization source: AbpZero DEBUG 2022-02-15 12:56:20,330 [1 ] Abp.Localization.LocalizationManager - Initialized localization source: QMP3


12 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Could you check log path in log4net.Production.config on the Azure ? Does it have a valid path for the log file ?

    Similar to https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Host/log4net.Production.config#L4

  • User Avatar
    0
    uabel created

    Hello, yes that is correct and the log is also written. It just always stops after the following line: DEBUG 2022-02-17 14:35:43,675 [1 ] Abp.Modules.AbpModuleManager - 13 modules loaded.

    Could it have something to do with this: https://issues.apache.org/jira/browse/LOG4NET-178

    We tried to update log4net and the Caste, but apparently there is still a dependency in ABP on the old version.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @uabel

    I'm not sure but probably it is not related to https://issues.apache.org/jira/browse/LOG4NET-178 because it is a very old issue.

    Do you face the same problem on your local environment or is it just the Azure ?

  • User Avatar
    0
    uabel created

    Hello, we have the problem only on Azure. We use ABP 0.7.5 and log4net 1.2.10. An update of ABP would unfortunately be relatively costly because we would have to adapt a lot.

  • User Avatar
    0
    sedulen created

    Hi @uabel ,

    I have been running ANZ projects on Azure for a few years now, and have had good success with logging. If you don't mind me asking, what are you running in Azure? VMs? AppServices? Docker Containers? AKS? And where are you trying to log the output to? Docker logs? Azure LogStash? or an external logging service?

    That being said, I'm running ABP v5.14.0 and log4net v2.0.14, so we may have very different outcomes. If you can give a bit more information around your Azure environment, I might be able to suggest somethings...

    -Brian

  • User Avatar
    0
    uabel created

    Hello, this is running on Azure App Services. We write the log to the file system.

    <?xml version="1.0" encoding="utf-8" ?> <log4net> <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender" > <file value="D:/Home/LogFiles/Log4Net/QMPilot.log" /> <appendToFile value="true" /> <rollingStyle value="Size" /> <maxSizeRollBackups value="10" /> <maximumFileSize value="10000KB" /> <staticLogFileName value="true" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%-5level %date [%-5.5thread] %-40.40logger - %message%newline" /> </layout> </appender> <root> <appender-ref ref="RollingFileAppender" /> <level value="DEBUG" /> </root> <logger name="NHibernate"> <level value="WARN" /> </logger> </log4net>

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Is "D:/Home/LogFiles/Log4Net/QMPilot.log" a valid path on your Azure environment ? It doesn't seem correct but I'm not much experienced with Azure.

  • User Avatar
    0
    uabel created

    Hello, yes the path is ok, and the log is also created.

    I am now testing another solution with a newer Log4Net version.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Please update us with the results of your test.

  • User Avatar
    0
    uabel created

    Hello, I tried it now with ABP 3.8.3 and Log4Net 2.0.8 in another project. There it goes without problems. So it could be because of the log4net version.

    We are now considering whether we can initialize a different logging framework in Global.aspx.

    AbpBootstrapper.IocManager.IocContainer .AddFacility<LoggingFacility>(f => f.UseAbpLog4Net() .WithConfig(Server.MapPath("log4net.config"))

    https://docs.microsoft.com/en-us/azure/azure-monitor/app/asp-net-trace-logs

  • User Avatar
    0
    uabel created

    Hello,. we have now tried Nlog, unfortunately there is the same problem.

    After that we tried to update the Castle Framework and Log4Net. Unfortunately this is not possible because there are dependencies in Abp.

    We then also tried to go to Abp 3.8.1, unfortunately there are so many changes (tenant management) etc. that this is probably very expensive. Is there a good way to

    Greetings Uwe Abel

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @uabel

    Could you try the raw C# file operations to write a text to that file ? In that way, we can see if your web app can write a text to that file or not.

    If it doesn't work, could you provide a temporary access to your azure app for us to check this problem ?

    Thanks,