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

[Log4Net]: Adds snippet showing how to set Log4Net properties as Google Cloud log entry labels. #5618

Merged
merged 1 commit into from
Nov 19, 2020

Conversation

amanda-tarafa
Copy link
Contributor

Towards #5325

@amanda-tarafa amanda-tarafa requested a review from a team as a code owner November 18, 2020 18:31
@amanda-tarafa amanda-tarafa self-assigned this Nov 18, 2020
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Nov 18, 2020
Copy link
Collaborator

@jskeet jskeet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of suggestions, but nothing major.

// Resource: log4net-custom-labels-template.xml log4net_custom_labels_template
// Sample: Custom_Labels
// Configure log4net to use Google Cloud Logging from the XML configuration file.
XmlConfigurator.Configure(LogManager.GetRepository(GetType().GetTypeInfo().Assembly), new FileInfo("log4net.xml"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect GetTypeInfo() can be removed everywhere now - we only didn't have it in netstandard1.*

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, will remove from all snippets.

// Set a property using one of the GlobaContext, ThreadContext or LogicalThreadContext classes.
LogicalThreadContext.Properties["property_for_label"] = "my label value";
// Log some information. This log entry will be sent to Google Cloud Logging with a label
// {"label_from_property", "my label value"}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly explain that the mapping from "property_for_label" to "label_from_property" is part of the configuration? I thought this was a typo at first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep!

Copy link
Contributor Author

@amanda-tarafa amanda-tarafa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments adressed. Will merge on green save objections. Thanks!

// Resource: log4net-custom-labels-template.xml log4net_custom_labels_template
// Sample: Custom_Labels
// Configure log4net to use Google Cloud Logging from the XML configuration file.
XmlConfigurator.Configure(LogManager.GetRepository(GetType().GetTypeInfo().Assembly), new FileInfo("log4net.xml"));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, will remove from all snippets.

// Set a property using one of the GlobaContext, ThreadContext or LogicalThreadContext classes.
LogicalThreadContext.Properties["property_for_label"] = "my label value";
// Log some information. This log entry will be sent to Google Cloud Logging with a label
// {"label_from_property", "my label value"}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep!

@amanda-tarafa amanda-tarafa merged commit 6182aa4 into googleapis:master Nov 19, 2020
@amanda-tarafa amanda-tarafa deleted the log4net-labels branch November 19, 2020 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants