dotnet / orleans

Cloud Native application framework for .NET
https://docs.microsoft.com/dotnet/orleans
MIT License
10.07k stars 2.03k forks source link

orleans client in mvc5 How to enable logging #3434

Closed noobwu closed 7 years ago

noobwu commented 7 years ago

orleans client in mvc5 How to enable logging

Qoooooooooooo commented 7 years ago

I have this problem, too :(

xiazen commented 7 years ago

which version of Orleans are you using?

Qoooooooooooo commented 7 years ago

@xiazen 1.5.1

ronMilne commented 7 years ago

How are you configuring your client?

xiazen commented 7 years ago

If you are configuring your client through xml config, then you can configure logging through xml. an example below:

 <Tracing DefaultTraceLevel="Info" TraceToConsole="true" TraceToFile="{0}-{2}-{1}.log" WriteMessagingTraces="false">
    <TraceLevelOverride LogPrefix="Application" TraceLevel="Info" />
    <TraceLevelOverride LogPrefix="AssemblyLoader.Client" TraceLevel="Warning" />
  </Tracing>

If you are configuring your client programmatically, then you can configure logging through ClientConfiguration by modifying its trace related properties.

noobwu commented 7 years ago

I use github master version,use NLog.Extensions.Logging, an example below: GrainClient.ConfigureLoggingDelegate = logBuilder => { logBuilder.AddNLog(); NLogConfigureExtensions.ConfigureNLog(HostingEnvironment.MapPath("~/App_Data/Configs/NLog.config")); }; GrainClient.Initialize(config);

xiazen commented 7 years ago

are you just playing around with master? In master everything is migrated to MEL technically, except for some remaining tasks needed to be finished, see #3303. In master version, you can configure through ISiloHostBuilder, ICientBuilder, both of which have ConfigureLogging extension methods on them. You can configure through GrainClient.ConfigureLoggingDelegate like in your example.

Qoooooooooooo commented 7 years ago

config example: `

    <TraceLevelOverride LogPrefix="Application" TraceLevel="Warning" />
    <TraceLevelOverride LogPrefix="AssemblyLoader" TraceLevel="Warning" />
</Tracing>`

only .Net Framework Web Project's _OrleansLog folder has not log files. but, .Net Core Web Project's _OrleansLog folder has log files, and .Net Framework console application Project's _OrleansLog folder has log files. @xiazen