postsharp / PostSharp.Community.Packer

Packs all your .dlls into your main executable so it becomes standalone
MIT License
8 stars 1 forks source link

Suppress logging to PostSharp.Patterns.Diagnostics #8

Open astrohart opened 2 years ago

astrohart commented 2 years ago

Hello,

When I utilize PostSharp.Community.Packer in conjunction with PostSharp.Patterns.Diagnostics, entries are written to my log file which I assume are from PostSharp.Community.Packer:

2022-06-28 12:22:22,849 INFO  - DebugUtils | *** LOG STARTED ON Tuesday, June 28, 2022 at 12:22:22 PM.
2022-06-28 12:22:22,939 DEBUG - Parse.CommandLine([ "-?" ]) | Starting.
2022-06-28 12:22:22,942 DEBUG -   CommandLineInfo..ctor() | Starting.
2022-06-28 12:22:22,943 DEBUG -   CommandLineInfo..ctor() | Succeeded.
2022-06-28 12:22:23,037 DEBUG -   ILTemplate.ResolveAssembly({Name:mysendmail.exe
There are no context policies.
}, {ResolveEventArgs}) | Starting.
2022-06-28 12:22:23,039 DEBUG -     Common.ReadExistingAssembly({mysendmail.CommandLine.Actions.resources, Version=1.0.0.0, Culture=en-US, PublicKeyToken=null}) | Starting.
2022-06-28 12:22:23,042 DEBUG -     Common.ReadExistingAssembly({mysendmail.CommandLine.Actions.resources, Version=1.0.0.0, Culture=en-US, PublicKeyToken=null}) | Succeeded: returnValue = null.
2022-06-28 12:22:23,047 DEBUG -     Common.Log("Loading assembly '{0}' into the AppDomain", [ {mysendmail.CommandLine.Actions.resources, Version=1.0.0.0, Culture=en-US, PublicKeyToken=null} ]) | Starting.
2022-06-28 12:22:23,048 DEBUG -     Common.Log("Loading assembly '{0}' into the AppDomain", [ {mysendmail.CommandLine.Actions.resources, Version=1.0.0.0, Culture=en-US, PublicKeyToken=null} ]) | Succeeded.
2022-06-28 12:22:23,063 DEBUG -     Common.ReadFromEmbeddedResources([ {[alphafs, costura.alphafs.dll.compressed]}, {[fluentcommandlineparser, costura.fluentcommandlineparser.dll.compressed]}, {[log4net, costura.log4net.dll.compressed]}, {[mysendmail.commandline.actions, costura.mysendmail.commandline.actions.dll.compressed]}, {[mysendmail.commandline, costura.mysendmail.commandline.dll.compressed]}, and 7 more ], [ {[alphafs, costura.alphafs.pdb.compressed]}, {[fluentcommandlineparser, costura.fluentcommandlineparser.pdb.compressed]}, {[mysendmail.commandline.actions, costura.mysendmail.commandline.actions.pdb.compressed]}, {[mysendmail.commandline.interfaces, costura.mysendmail.commandline.interfaces.pdb.compressed]}, {[mysendmail.commandline, costura.mysendmail.commandline.pdb.compressed]}, and 1 more ], {mysendmail.CommandLine.Actions.resources, Version=1.0.0.0, Culture=en-US, PublicKeyToken=null}) | Starting.
2022-06-28 12:22:23,065 DEBUG -       Common.LoadStream([ {[alphafs, costura.alphafs.dll.compressed]}, {[fluentcommandlineparser, costura.fluentcommandlineparser.dll.compressed]}, {[log4net, costura.log4net.dll.compressed]}, {[mysendmail.commandline.actions, costura.mysendmail.commandline.actions.dll.compressed]}, {[mysendmail.commandline, costura.mysendmail.commandline.dll.compressed]}, and 7 more ], "en-US.mysendmail.commandline.actions.resources") | Starting.
2022-06-28 12:22:23,066 DEBUG -       Common.LoadStream([ {[alphafs, costura.alphafs.dll.compressed]}, {[fluentcommandlineparser, costura.fluentcommandlineparser.dll.compressed]}, {[log4net, costura.log4net.dll.compressed]}, {[mysendmail.commandline.actions, costura.mysendmail.commandline.actions.dll.compressed]}, {[mysendmail.commandline, costura.mysendmail.commandline.dll.compressed]}, and 7 more ], "en-US.mysendmail.commandline.actions.resources") | Succeeded: returnValue = null.
2022-06-28 12:22:23,067 DEBUG -     Common.ReadFromEmbeddedResources([ {[alphafs, costura.alphafs.dll.compressed]}, {[fluentcommandlineparser, costura.fluentcommandlineparser.dll.compressed]}, {[log4net, costura.log4net.dll.compressed]}, {[mysendmail.commandline.actions, costura.mysendmail.commandline.actions.dll.compressed]}, {[mysendmail.commandline, costura.mysendmail.commandline.dll.compressed]}, and 7 more ], [ {[alphafs, costura.alphafs.pdb.compressed]}, {[fluentcommandlineparser, costura.fluentcommandlineparser.pdb.compressed]}, {[mysendmail.commandline.actions, costura.mysendmail.commandline.actions.pdb.compressed]}, {[mysendmail.commandline.interfaces, costura.mysendmail.commandline.interfaces.pdb.compressed]}, {[mysendmail.commandline, costura.mysendmail.commandline.pdb.compressed]}, and 1 more ], {mysendmail.CommandLine.Actions.resources, Version=1.0.0.0, Culture=en-US, PublicKeyToken=null}) | Succeeded: returnValue = null.
2022-06-28 12:22:23,068 DEBUG -   ILTemplate.ResolveAssembly({Name:mysendmail.exe
There are no context policies.
}, {ResolveEventArgs}) | Succeeded: returnValue = null.
2022-06-28 12:22:23,069 DEBUG -   ILTemplate.ResolveAssembly({Name:mysendmail.exe
There are no context policies.
}, {ResolveEventArgs}) | Starting.
2022-06-28 12:22:23,070 DEBUG -   ILTemplate.ResolveAssembly({Name:mysendmail.exe
There are no context policies.
}, {ResolveEventArgs}) | Succeeded: returnValue = null.
2022-06-28 12:22:23,079 DEBUG -   ILTemplate.ResolveAssembly({Name:mysendmail.exe
There are no context policies.
}, {ResolveEventArgs}) | Starting.
2022-06-28 12:22:23,080 DEBUG -     Common.ReadExistingAssembly({mysendmail.CommandLine.Actions.resources, Version=1.0.0.0, Culture=en, PublicKeyToken=null}) | Starting.
2022-06-28 12:22:23,081 DEBUG -     Common.ReadExistingAssembly({mysendmail.CommandLine.Actions.resources, Version=1.0.0.0, Culture=en, PublicKeyToken=null}) | Succeeded: returnValue = null.
2022-06-28 12:22:23,081 DEBUG -     Common.Log("Loading assembly '{0}' into the AppDomain", [ {mysendmail.CommandLine.Actions.resources, Version=1.0.0.0, Culture=en, PublicKeyToken=null} ]) | Starting.
2022-06-28 12:22:23,082 DEBUG -     Common.Log("Loading assembly '{0}' into the AppDomain", [ {mysendmail.CommandLine.Actions.resources, Version=1.0.0.0, Culture=en, PublicKeyToken=null} ]) | Succeeded.
2022-06-28 12:22:23,082 DEBUG -     Common.ReadFromEmbeddedResources([ {[alphafs, costura.alphafs.dll.compressed]}, {[fluentcommandlineparser, costura.fluentcommandlineparser.dll.compressed]}, {[log4net, costura.log4net.dll.compressed]}, {[mysendmail.commandline.actions, costura.mysendmail.commandline.actions.dll.compressed]}, {[mysendmail.commandline, costura.mysendmail.commandline.dll.compressed]}, and 7 more ], [ {[alphafs, costura.alphafs.pdb.compressed]}, {[fluentcommandlineparser, costura.fluentcommandlineparser.pdb.compressed]}, {[mysendmail.commandline.actions, costura.mysendmail.commandline.actions.pdb.compressed]}, {[mysendmail.commandline.interfaces, costura.mysendmail.commandline.interfaces.pdb.compressed]}, {[mysendmail.commandline, costura.mysendmail.commandline.pdb.compressed]}, and 1 more ], {mysendmail.CommandLine.Actions.resources, Version=1.0.0.0, Culture=en, PublicKeyToken=null}) | Starting.
2022-06-28 12:22:23,083 DEBUG -       Common.LoadStream([ {[alphafs, costura.alphafs.dll.compressed]}, {[fluentcommandlineparser, costura.fluentcommandlineparser.dll.compressed]}, {[log4net, costura.log4net.dll.compressed]}, {[mysendmail.commandline.actions, costura.mysendmail.commandline.actions.dll.compressed]}, {[mysendmail.commandline, costura.mysendmail.commandline.dll.compressed]}, and 7 more ], "en.mysendmail.commandline.actions.resources") | Starting.
2022-06-28 12:22:23,083 DEBUG -       Common.LoadStream([ {[alphafs, costura.alphafs.dll.compressed]}, {[fluentcommandlineparser, costura.fluentcommandlineparser.dll.compressed]}, {[log4net, costura.log4net.dll.compressed]}, {[mysendmail.commandline.actions, costura.mysendmail.commandline.actions.dll.compressed]}, {[mysendmail.commandline, costura.mysendmail.commandline.dll.compressed]}, and 7 more ], "en.mysendmail.commandline.actions.resources") | Succeeded: returnValue = null.
2022-06-28 12:22:23,083 DEBUG -     Common.ReadFromEmbeddedResources([ {[alphafs, costura.alphafs.dll.compressed]}, {[fluentcommandlineparser, costura.fluentcommandlineparser.dll.compressed]}, {[log4net, costura.log4net.dll.compressed]}, {[mysendmail.commandline.actions, costura.mysendmail.commandline.actions.dll.compressed]}, {[mysendmail.commandline, costura.mysendmail.commandline.dll.compressed]}, and 7 more ], [ {[alphafs, costura.alphafs.pdb.compressed]}, {[fluentcommandlineparser, costura.fluentcommandlineparser.pdb.compressed]}, {[mysendmail.commandline.actions, costura.mysendmail.commandline.actions.pdb.compressed]}, {[mysendmail.commandline.interfaces, costura.mysendmail.commandline.interfaces.pdb.compressed]}, {[mysendmail.commandline, costura.mysendmail.commandline.pdb.compressed]}, and 1 more ], {mysendmail.CommandLine.Actions.resources, Version=1.0.0.0, Culture=en, PublicKeyToken=null}) | Succeeded: returnValue = null.
2022-06-28 12:22:23,084 DEBUG -   ILTemplate.ResolveAssembly({Name:mysendmail.exe
There are no context policies.
}, {ResolveEventArgs}) | Succeeded: returnValue = null.
2022-06-28 12:22:23,084 DEBUG -   ILTemplate.ResolveAssembly({Name:mysendmail.exe
There are no context policies.
}, {ResolveEventArgs}) | Starting.
2022-06-28 12:22:23,085 DEBUG -   ILTemplate.ResolveAssembly({Name:mysendmail.exe
There are no context policies.
}, {ResolveEventArgs}) | Succeeded: returnValue = null.
2022-06-28 12:22:24,918 DEBUG - Parse.CommandLine([ "-?" ]) | Succeeded: returnValue = {CommandLineInfo}.
2022-06-28 12:22:24,920 DEBUG - DebugUtils | Program.Main: Result = 0.

I suppose, in principle, this is a good thing, as it helps us diagnose if there are any issues with PostSharp.Community.Packer; however, for my use case, I would like to disable/suppress logging for the PostSharp.Community.Packer content.

Is there an aspect I can put in, e.g., my GlobalAspects.cs file to in order to suppress the logging that is not from my own software?

Thank you.

Regards,

Brian Hart

addabis commented 2 years ago

PostSharp.Community.Packer (and Fody.Costura which is the origin of this repo) do include .cs files in the project to facilitate the assembly loading functionality.

Since you are probably multicasting [Log] onto the whole assembly, you include logging of these runtime methods, which are executed immediately after program's execution are meant to register handler for loading referenced assemblies. You are seeing output of logging of these methods.

The solution is to simply exclude logging from PostSharp.Community.Packer.Templates namespace, i.e.:

[assembly: Log(AttributeExclude = true, AttributeTargetTypes = "PostSharp.Community.Packer.Templates*", AttributePriority = 2)]

We will document this in the readme file.