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

Support of constructor parameters #188

Closed
wants to merge 1 commit into from
Closed

Support of constructor parameters #188

wants to merge 1 commit into from

Conversation

vhatsura
Copy link

@vhatsura vhatsura commented Jun 25, 2019

related to #167

Hey, guys! It's an early draft pull request with implementation of possiblity to create object via constructors with parameters. I will be appreciate if you can take a look and add your feedback

@nblumhardt
Copy link
Member

Thanks! Short on time but will try to loop back around. What was the situation in which you found yourself needing this? (I've seen several 👍)

@vhatsura
Copy link
Author

In my case I use ExceptionAsObjectJsonFormatter from Serilog.Formatting.Elasticsearch. The formatter has a lot of arguments and sometimes we need to override them. This is why ability to configure constructor arguments in configuration is nice to have

@julealgon
Copy link

@nblumhardt , what's the status on this? I just stumbled upon this problem today when introducing file logging in one of our solutions, and realizing I needed to set the renderMessage argument on JsonFormatter to true.

Would be really useful to have first-class support for configuring complex/abstract instances with parameters in config files.

@tsimbalar
Copy link
Member

@julealgon for now, you might want to use a workaround such as the one described in
serilog/serilog-sinks-console#28

or follow indications in https://github.com/tsimbalar/serilog-settings-comparison/blob/master/docs/README.md#interfaces-and-abstract-classes , and make a Formatter configured the way you want it either as :

  • a custom class with a default constructor
  • a static property on your own type

@tzographos
Copy link

@julealgon for now, you might want to use a workaround such as the one described in
serilog/serilog-sinks-console#28

Hello @tsimbalar. How's this solving the problem where there is a need to configure a TextFormatter with constructor arguments (non-parameterless constructor)?

@tsimbalar
Copy link
Member

@tzographos you're right, there is nothing about this in serilog/serilog-sinks-console#28 ... no idea what I meant back then 🤔

@skomis-mm
Copy link
Contributor

skomis-mm commented Aug 26, 2021

Hi @vhatsura ,
Sorry for the long delay on this one. The feature become high requested with the new ExpressionTemplate.

Are you still interested to work on this? I made a workable sketch for a complete solution, but first would like to know your opinion if you still interested.

@skomis-mm
Copy link
Contributor

Ok, I've just created the new one with additional features. Feel free to comment/review :)

@skomis-mm skomis-mm closed this Aug 30, 2021
@vhatsura vhatsura deleted the constructor_values branch October 4, 2021 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants