Base solution for your next web application
Open Closed

Log4Net configuration #8050


User avatar
1
BobIngham created

dotnet-core, angular, 4.6.1 framework: 6.8.1 Current log4net configuration reads:

<layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%-5level %date [%-5.5thread] %-40.40logger - %message%newline" />
</layout>

Whereas the standard outlines at Apache log4netâ„¢ Config Examples reads:

<layout type="log4net.Layout.PatternLayout">
    <conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>

Can anyone tell me what [%-5.5thread] and %-40.40logger (note decimal) denotes and what is [%property{NDC}] and why don't we have it? I would like to push my logs to Application Insights and I'm trying to get some more detail on what to capture. Any help anyone? Any pointers to documentation?


7 Answer(s)
  • User Avatar
    0
    hikalkan created
    Support Team

    [%-5.5thread] is the current thread name/id. %-40.40logger is the name of the class that writes the log line. 5 & 40 are the spaces allocated in the log line for the information. I don't know the [%property{NDC}] :) You can find more info on the web, log4net has an independent library and we are directly using it.

  • User Avatar
    0
    BobIngham created

    @hilkakan, thanks. Is that why the first two characters are always missing from the line %-40.40logger variable? Should I raise a github issue for this?

    WARN  2019-11-24 23:32:37,541 [4    ] calization.RequestLocalizationMiddleware - AbpUserRequestCultureProvider returned the following unsupported cultures 'null'.
    WARN  2019-11-24 23:32:37,567 [4    ] calization.RequestLocalizationMiddleware - AbpUserRequestCultureProvider returned the following unsupported UI Cultures 'null'.
    WARN  2019-11-24 23:32:37,569 [4    ] calization.RequestLocalizationMiddleware - AbpDefaultRequestCultureProvider returned the following unsupported cultures 'null'.
    WARN  2019-11-24 23:32:37,570 [4    ] calization.RequestLocalizationMiddleware - AbpDefaultRequestCultureProvider returned the following unsupported UI Cultures 'null'.
    INFO  2019-11-24 23:32:37,544 [99   ] uthentication.JwtBearer.JwtBearerHandler - Successfully validated the token.
    INFO  2019-11-24 23:32:37,594 [47   ] soft.AspNetCore.Hosting.Internal.WebHost - Request starting HTTP/1.1 GET http://localhost:22742/api/services/app/UserLink/GetLinkedUsers?MaxResultCount=7&SkipCount=0  
    WARN  2019-11-24 23:32:37,594 [99   ] calization.RequestLocalizationMiddleware - AbpUserRequestCultureProvider returned the following unsupported cultures 'null'.
    WARN  2019-11-24 23:32:37,617 [99   ] calization.RequestLocalizationMiddleware - AbpUserRequestCultureProvider returned the following unsupported UI Cultures 'null'.
    INFO  2019-11-24 23:32:37,571 [4    ] ft.AspNetCore.Routing.EndpointMiddleware - Executing endpoint 'Nuagecare.Authorization.Users.UserLinkAppService.GetRecentlyUsedLinkedUsers (Nuagecare.Application)'
    WARN  2019-11-24 23:32:37,618 [99   ] calization.RequestLocalizationMiddleware - AbpDefaultRequestCultureProvider returned the following unsupported cultures 'null'.
    WARN  2019-11-24 23:32:37,642 [99   ] calization.RequestLocalizationMiddleware - AbpDefaultRequestCultureProvider returned the following unsupported UI Cultures 'null'.
    INFO  2019-11-24 23:32:37,594 [47   ] pNetCore.Cors.Infrastructure.CorsService - CORS policy execution successful.
    
  • User Avatar
    0
    hikalkan created
    Support Team

    Should I raise a github issue for this?

    I think it makes the log line too long. Even if we make it longer, some namespaces will be too deep and it will not cover all names. The essential point is the class name (like RequestLocalizationMiddleware in the log you've shared), namespace is not so important. But if you like, you can do it for your own solution.

  • User Avatar
    0
    BobIngham created

    Hi @hilkakan, Sorry I don't get that. Are you saying that if the %-40.40logger variable is 128 characters long the log will just show the last 40 characters and ignore the first 88? Is this so the text file created by the log will always have the - %message%newline variable starting at exactly the same column number? It's not a criticism, just a simple question, my logs are being sent to Application Insights so I can make changes to my own project. I would just like confirmation on what the standard default is.

  • User Avatar
    0
    ismcagdas created
    Support Team

    @bobingham

    Yes, that is exactly how it works.

  • User Avatar
    0
    BobIngham created

    Thanks.

  • User Avatar
    0
    VuCA created

    Hello,

    I want to log some info: client ip, current user => I configed and it work with .net framework project but i does't work with .net core project.

    %identity => user name %aspnet-request{REMOTE_ADDR} => client ip

    What properties are the same with .net core?

    Thanks!