Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: OnNewLogFile Method Hook / Event Handler #3814

Closed
Brondahl opened this issue Feb 21, 2020 · 8 comments
Closed

Feature: OnNewLogFile Method Hook / Event Handler #3814

Brondahl opened this issue Feb 21, 2020 · 8 comments

Comments

@Brondahl
Copy link

See this StackOverflow question:

https://stackoverflow.com/questions/60335551/nlog-onnewlogfile-handler

On the assumption that it doesn't currently exist, would you be open to adding such a config option?

NLog version: vNext?

Platform: N/A

Current NLog config: N/A?

  • Why do we need it?
    So that (if desired) you can ensure that All log files contain relevant contextual information. Aiding in debugging production issues.

  • An example of the XML config, if relevant.
    IDK.
    Possibly something very similar to the MethodCall target functionality?

@welcome
Copy link

welcome bot commented Feb 21, 2020

Hi! Thanks for opening your first issue here! Please make sure to follow the issue template - so we could help you better!

@Brondahl Brondahl changed the title OnNewLogFile Method Hook / Event Handler Feature: OnNewLogFile Method Hook / Event Handler Feb 21, 2020
@Brondahl
Copy link
Author

Supposing you were on board with the concept, would you welcome a PR for this, from a new contributor?

@304NotModified
Copy link
Member

I doubting if this really suitable for NLog Core. Another option is to make the File target extensible enough to handle this.

Possibly something very similar to the MethodCall target functionality?

I think c# events are a better way for this

@304NotModified
Copy link
Member

related #1249

@snakefoot
Copy link
Contributor

Sounds like you are really looking for the Header-Layout on the FileTarget.

    <target name="logfile" xsi:type="File">
             <header>--- ${assembly-version} started on ${longdate} ---</header>
    </target>

See also https://github.com/NLog/NLog/wiki/File-target

@Brondahl
Copy link
Author

Brondahl commented Feb 21, 2020

🤣 Yes. Yes, it does indeed.
Internet points have been award on SO.

@snakefoot
Copy link
Contributor

snakefoot commented Feb 21, 2020

Some combine it with archiveOldFileOnStartup because the Header is only printed when file is created (ensure application restarts will create new file). See also #2119

@304NotModified
Copy link
Member

Closing this as the header layout is fine here and no upvotes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants