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

How can I get machine name into variable ? #62

Open
LightWeight-POS opened this issue May 24, 2024 · 2 comments
Open

How can I get machine name into variable ? #62

LightWeight-POS opened this issue May 24, 2024 · 2 comments

Comments

@LightWeight-POS
Copy link

I don't want to use Properties column for MSSQL and want to have a single column with machine name and have it's value in the table.

I tried below to retrieve machine name and other properties:

var machineName = new LoggerConfiguration().Enrich.WithMachineName().ToString();
var environmentUserName = new LoggerConfiguration().Enrich.WithEnvironmentUserName().ToString();
var environmentName = new LoggerConfiguration().Enrich.WithEnvironmentName().ToString();
var threadID = new LoggerConfiguration().Enrich.WithThreadId().ToString();
var threadName = new LoggerConfiguration().Enrich.WithThreadName().ToString();
var processID = new LoggerConfiguration().Enrich.WithProcessId().ToString();
var processName = new LoggerConfiguration().Enrich.WithProcessName().ToString();

However, in database they are not coming right and even in variable:

image

Is there any possibility that I get them in variable and insert in to custom columns of my own ?

@Numpsy
Copy link
Member

Numpsy commented May 26, 2024

I guess that calling ToString() on the enricher classes will just do the default behavior of stringifying the class name.

Are you using the Serilog SQL sink for writing to the database?
If so there are some docs at https://github.com/serilog-mssql/serilog-sinks-mssqlserver?tab=readme-ov-file#custom-property-columns for writing custom properties into custom SQL columns.

@LightWeight-POS
Copy link
Author

I have gone through docs and none of them show that specific thing that I want to acheive. I want to insert all those columns as shown above in code.

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

No branches or pull requests

2 participants