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-586 provide log4j like XML Layout that works on .NET Core 1.x #22

Closed
wants to merge 10 commits into from

Conversation

bodewig
Copy link
Member

@bodewig bodewig commented May 30, 2018

No description provided.

@dpsenner
Copy link
Member

There is a lot of whitespace changes in this PR which makes it tough to review. Would you mind to apply those changes onto develop and only keep the changes/features in this PR?

/// <summary>
/// The namespace URI to use for the elements and attributes written by this layout.
/// </summary>
public virtual string NamespaceUri
Copy link
Member

@dpsenner dpsenner May 30, 2018

Choose a reason for hiding this comment

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

Do we need this property with a backing field to be virtual?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've decided to override the getters rather than setting default values in ActivateOptions or the constructor.

Copy link
Member

@dpsenner dpsenner Jun 1, 2018

Choose a reason for hiding this comment

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

As far as I can tell, ActivateOptions is in existing appenders or layouts the place where configurations are applied. Other parts should not provide mechanisms to customize behavior because that means that ActivateOptions is no longer the source of the one and only truth.

Copy link
Member Author

Choose a reason for hiding this comment

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

it's about providing a default value, not really customizing anything. I'd move it to the constructor and make the properties non-virtual unless you prefer to get rid of the base class completely.

Copy link
Member Author

Choose a reason for hiding this comment

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

changed by now.

/// </para>
/// </remarks>
public virtual string Prefix
{
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this to be virtual?

/// </para>
/// </remarks>
abstract public class XmlLayoutBaseNS : LayoutSkeleton
{
Copy link
Member

Choose a reason for hiding this comment

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

Would you please explain the reasoning behind this base class? As far as I can tell we could reduce both the inheritance complexity and the public api without it. I discourage inheritance and encourage composition when there is need for it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Initially I planned to also create a replacement of XmlLayout as it suffers from the same problems if you specify a prefix. I'm not sure this is something people need anymore, in which case we can merge the classes.

Copy link
Member

Choose a reason for hiding this comment

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

Does this indicate that we should rather implement a XmlFormatter class that can be plugged into various appenders? This is the composition what I have in mind and that we should prefer over inheritance.

Copy link
Member Author

Choose a reason for hiding this comment

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

The layout is what gets plugged into the appenders, isn't it? The whole structure of XmlLayoutBaseNS and XmlLayoutSchemaLog4jNS just mimics what has been there before - an area of code I never really looked into so far.

/// handle XML using namespaces.
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
Copy link
Member

Choose a reason for hiding this comment

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

You are not nicko, are you? 😋

Copy link
Member Author

Choose a reason for hiding this comment

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

but he's written most of the code I copied :-)

Copy link
Member

Choose a reason for hiding this comment

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

That's probably fine, then.

@@ -28,7 +28,7 @@
namespace log4net.Layout
{
/// <summary>
/// Layout that formats the log events as XML elements compatible with the log4j schema
/// Layout that formats the log events as XML elements compatible with the log4j 1.2 schema
Copy link
Member

Choose a reason for hiding this comment

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

The newly added layout class claims to do this, too. Would you please explain this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

the class has a version field for historical reasons but only accepts 1.2 as value. To me it is more important to say it is the 1.x version and not the 2.x version of log4j.

Copy link
Member

Choose a reason for hiding this comment

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

If that's the case, fine with me.

/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
public class XmlLayoutSchemaLog4jNS : XmlLayoutBaseNS
Copy link
Member

Choose a reason for hiding this comment

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

Would we like to have the version in the class name, too? If tomorrow there is to be 1.3 layout we have no place to put that.

Copy link
Member Author

Choose a reason for hiding this comment

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

2.0 rather than 1.3 - I wanted to keep symmetry with the existing class name.

Copy link
Member

Choose a reason for hiding this comment

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

So here we could actually really make use of a XmlFormatter class that provides mechanisms to format logging events in various formats. To mention a few we're already having today:

  • log4j_1.2
  • log4j_1.2_with_namespace

This could be provided by one and only one layout (XmlLayoutSchemaLog4j?) which in turn can be configured to either be in format 1.2 or 1.2 with namespaces etc.. This would also create a place for future 2.0 layouts to live in. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

The responsibility of the layout is formatting, I don't really see what an additional formatter would do. Please note that we need to configure XmlWriter in different ways for the "no namespace" and "with namespace" cases.

@bodewig
Copy link
Member Author

bodewig commented May 30, 2018

The whitespace changes are inside a separate commit - ec82f5b - I'll cherry-pick it to develop and rebase this branch.

@fluffynuts
Copy link
Contributor

Good day

It's been quite a while since this PR last saw activity. In an attempt to get pull requests under some semblance of
order, I'm having to make the uncomfortable decision to jettison pull requests which have been dormant for quite some
time. Perhaps arbitrarily, I'm choosing all pull requests which have not seen activity this year (2021), most of
which are marked as not building or have conflicts with the main branch.

This is not because the contributions aren't valuable - it's simply a matter of being the only person spending
some time on this and being a little overwhelmed. I'd rather get some traction on newer issues than continue
to try to understand, upgrade and work through PRs which don't build or which conflict with the main branch,
or which simply may have been solved in the mean time.

I encourage you to re-submit the PR against the current main branch if the issue is still significant. Your
contributions are appreciated. I apologise for any inconvenience caused and sincerely hope that you understand
the constraints involved which have brought me to the place of making this decision.

@fluffynuts fluffynuts closed this Oct 25, 2021
@fluffynuts fluffynuts deleted the feature/LOG4NET-586 branch November 2, 2021 06:51
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.

None yet

3 participants