Interfering options to reference Logback config file, starting with Micronaut 3.8 - logback

As far as I can see, starting with Micronaut 3.8, there has been added another option to configure referenced Logback's
XML config file within application.yml file(s), as described also in current
Micronaut documentation.
This results in sometimes weird logging behaviour!
I've described my observations, details, my course of investigation, and reference to a stripped down Micronaut test
project in
another StackOverflow thread.
To sum it up:
Option to reference custom Logback XML configuration file also within application.yml file
does NOT affect log messages issued before final setup of Micronaut's ApplicationContext, like often the case
with frameworks like OR mappers (even if they get set up in response to configs laid down in application.yml
file itself), and
interferes with option to reference Logback XML config file via JVM CLI switch (like
-Dlogback.configurationFile=logback-json-format.xml). To me it seems that both config options (JVM CLI switch
and application.yml) have to be in sync to gain expected behaviour.
So I propose to
make reference to Logback XML configurations in application.yml files count from "the beginning" (if at all
possible), and
establish a priority between both config options, like "JVM CLI switch supersedes config in application.yml"
in this regard, and/or
make io.micronaut.logging.impl.LogbackLoggingSystem be aware of mentioned JVM CLI switch.
Otherwise I'm not sure if the option to configure custom Logback XML file within application.yml is that valuable in
the light of all the "troubles".

Related

Change Kubernetes log format to json at create or runtime?

I would like to change the default Kubernetes log format to "json" for system logs at "create" or preferably at "runtime".
The documentation designates the --logging-format=json for this purpose. However, I have been unable to identify what command-line call I would use to specific this flag.
I have tried kube-apiserver and kind cmd-line with no luck so far.
I am currently using Kind, but any reference related to Kube would be fine.
Questions:
Does this need be at "create" for the cluster?
If runtime is ok, what cmd util would I use to change a cluster configuration at runtime?
Do I need to apply a configuration with "kubectl" with a yaml file?

How do I correctly start using .readthedocs.yml

I have a basic ReadTheDocs repository. As per the advice of the build page, I sought to use a .readthedocs.yml to configure it:
Configure your documentation builds! Adding a .readthedocs.yml file to your project is the recommended way to configure your documentation builds. You can declare dependencies, set up submodules, and many other great features.
I added a basic .readthedocs.yml:
version: 2
sphinx:
builder: dirhtml
fail_on_warning: true
and got a build failure:
Problem in your project's configuration. Invalid "sphinx.builder": .readthedocs.yml: Your project is configured as "Sphinx Html" in your admin dashboard, but your "sphinx.builder" key does not match.
This was surprising as it seemed contrary to the guidance in the admin dashboard at https://readthedocs.org/dashboard/PROJECTNAME/advanced/ which led me to assume that I could set whatever I liked in the admin dashboard, but it would be overridden by my .readthedocs.yml (which is the behaviour I expected and wanted):
These settings can be configured using a configuration file. That's the recommended way to set up your project. Settings in the configuration file override the settings listed here.
I updated the setting in the admin dashboard to match the .readthedocs.yml and then got a build error:
Sphinx error:
master file /home/docs/checkouts/readthedocs.org/user_builds/PROJECT_NAME/checkouts/latest/source/contents.rst not found
which looks like https://github.com/readthedocs/readthedocs.org/issues/2569 (RTD not finding Sphinx configuration) - but it's not clear why that's happening because prior to adding .readthedocs.yml, the project built just fine.
I'm struggling to model what's actually going on here:
The config file isn't acting as an "overlay" / "override" onto the web settings - as per the first error, some forms of disagreement are a build failure
It's almost like if the config file exists, the web config is ignored - this would explain the contents.rst issue arising, but this isn't consistent with the first error
Adding a python.install entry to .readthedocs.yml eventually got the site building, but it's still not clear to me if I'm generally doing the right thing, and/or how successful future config changes will be.
The reason you're getting the error is that the sphinx version you're using locally doesn't match with the version readthedocs is using at the time you initiated the build process.
See here: You can use a requirements.txt file to use the same version of sphinx you use locally. I had the same issue. I've solved it by simply adding my version Sphinx==3.1.2
Also, I added a .readthedocs.yml file in my project directory where docs/ resides, pointing to where the conf.py because
I was using an extension sphinxcontrib.napoleon which readthedocs build process fails to recognize.
Wanted readthedocsbuild process to use a specific version on Sphinx.
# .readthedocs.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
# Required
version: 1
# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/source/conf.py
# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml
# Optionally build your docs in additional formats such as PDF
formats:
- pdf
# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: docs/requirements.txt
a
and added all the dependencies needed to generate the documentation in docs/requirement.txt
Babel==2.8.0
imagesize==1.2.0
readme-renderer==26.0
Sphinx==3.1.2
sphinx-argparse==0.2.5
sphinx-rtd-theme==0.5.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==1.0.3
sphinxcontrib-images==0.9.2
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-napoleon==0.7
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.4

unable to configure through carbon.xml

I am trying to configure wso2 by modifing its configuration file named "carbon.xml", but no matter what change I do to "carbon.xml", even adding a single "white space" or modifying a comment it's enough for the wso2 server to reset carbon.xml file to it´s original "out of the box" state.
I tryied to protect the file carbon.xml by dropping write permissions, but in this case wso2 server refuses to start, it aborts execution and displays an error complaining that it was not able to "write new configuration" !!!
Does any one know how to solve this?
I found the answer, In wso2 version 5.9 there is a new centralized configuration file, named "deployment.toml". Configurations must be done in this file and then wso2 propagates changes to the respective configurations files, like carbon.xml or catalina-server.xml, for example.
If you delete "deployment.toml" wso2 will fallback to previos behavior.
With the new 4.5.0 carbon-kernel release, all WSO2 products such as APIM 3.0.0, IS 5.9.0 introduced a new config model. According to the new config model, there is a centralized configuration file (deployment.toml) where users add the configurations, then those configurations will be added to the respective .xml files.
This new config model was introduced in order to simplify the configuration (previously there were a lot of configuration files) and to increase the user experience. Please follow this documentation to refer further information on this new config model
Related documents:
https://wso2.com/blogs/thesource/2019/10/simplifying-configuration-with-WSO2-identity-server
https://is.docs.wso2.com/en/next/references/new-configuration-model/
If you have a deployment.toml file, the changes directly made into the xml files will be overiden during the server startup. Deleting the deployment.toml file will use the old config model. But it is not a recommended approach.

How can I define an arbitrary file outside my web application to configure log4j2

My web application will be deployed to Weblogic application servers on Windows and Linux/Unix in different environments. The log file location, appenders and log levels will vary between the different deployments and we would like to be able to change the logging configuration during runtime (by exchanging the config file), so I cannot embed a log4j2.xml (or whatever other config file) into my deployment. And since I'm running on Application servers I cannot control, I've got no chance to add environment variables to point to another configuration Location.
Currently, my log4j2.xml resides in the classpath of my application and is being packaged into my war file. Is there any way to tell Log4J2 to use a configuration file e. g. relative to the application root (like Log4J's configureAndWatch(fileLocation) method)?
I found lots of examples of how to configure Log4J2, but everything I found about the config file location points to the applications class path.
I finally found a solution for my problem. I added a file named
log4j2.component.properties
to my project (in src/main/resources). This file contains a property pointing to the location of my log4j2 configuration file:
log4j.configurationFile=.//path//on//my//application//server//someLog4j2ConfigFile.xml
This causes log4j2 to read that file and configure itself from it's content.

Karaf how to exclude specified bundle from log

I would like to exclude my bundle from root karaf log. The JSON sended by this bundle is too large, and the log is no more readeable.
I suppose that I should change osgi:* in line :
rootLogger=INFO,out,osgi:*
Which value I should put there ?
Edit, the problem is more complicated that I thought.
The JSON sont injected in logs by org.apache.cxf.cxf-rt-features-logging. It is used also by other bundle. I vould like remove only JSON sending and receiving by my bundle.
How can I do this ?
If you want to exclude a specific bundle from logging, just turn off logging for the bundle within the pax logging config.
log4j.logger.mybundle = OFF
If you want to fine tune CXF message logging please check http://cxf.apache.org/docs/message-logging.html.
Some things to note:
The logger name is .. karaf by default only cuts it to just the type.
A lot of the details are in the MDC values
You need to change your pax logging config to make these visible.
You can use the logger name to fine tune which services you want to log this way. For example set the debug level to WARN for noisy
services to avoid that they are logged or log some services to another
file.