Can I modify Geode's default logging behavior? - log4j2

Geode's out-of-the-box logging behavior does not include the "name" of the logger on each line (usually the name of the class invoking the Log4j Logger). I want to add this field to the default logger configuration, the one that logs to <member-name>/<member-name>.log.
Using the instructions from the documentation, I was able to successfully configure an additional logger using the configuration below -- it writes to a separate file from the default (logs/app.log in this case), but the default configuration also still logs as normal to the default file.
My expectation would be that providing my own log4j2.xml would override the default configuration, not supplement it. Is there anything I can do to override the behavior of that default logger?
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="FATAL" shutdownHook="disable" packages="org.apache.geode.internal.logging.log4j">
<Properties>
<Property name="geode-pattern">[%level{lowerCase=true} %date{yyyy/MM/dd HH:mm:ss.SSS z} <%thread> tid=%tid] - %c - %message%n%throwable%n</Property>
<Property name="geode-default">true</Property>
</Properties>
<Appenders>
<File name="MyFile" fileName="logs/app.log">
<PatternLayout pattern="${geode-pattern}"/>
</File>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="MyFile"/>
</Root>
</Loggers>
</Configuration>

I don't see anything wrong with your configuration, actually I just tried it locally and the members only log to the configured file instead of the default:
$> gfsh start locator --name=locator1 --J=-Dlog4j.configurationFile=$CURRENT_DIRECTORY/log4j-custom.xml
$> gfsh -e "connect" -e "start server --name=server1 --J=-Dlog4j.configurationFile=$CURRENT_DIRECTORY/log4j-custom.xml"
$> gfsh -e "connect" -e "shutdown --include-locators=true"
$> tree -L 3
.
├── gfsh-0_0.log
├── locator1
│   ├── ConfigDiskDir_locator1
│   │   ├── BACKUPcluster_config.if
│   │   ├── BACKUPcluster_config_1.crf
│   │   ├── BACKUPcluster_config_1.drf
│   │   └── DRLK_IFcluster_config.lk
│   ├── GemFire_user
│   │   └── services
│   ├── locator10334view.dat
│   ├── locator10334views.log
│   ├── logs
│   │   └── app.log
│   └── vf.gf.locator.pid
├── log4j-custom.xml
└── server1
├── logs
│   └── app.log
└── vf.gf.server.pid
I've tried with the latest release, GemFire 9.9.1, maybe you're using an older version?, can you try with the latest one?.

Related

Remove some class file from all jars packaged in tar(each tar is a layer of a docker image)

OK so I know how to remove class files from all the jars under a dir. But, now I have different layer from a docker image, each layer is a tar file, and in the tar file there are the jar files.
Can I remove the class files from the jar files, packaged in tar files?
$ tree -L 3
.
├── 29e0fb8afe376cb02219c977cba1c9a80cca895f7f17b72c356f3e25a63337b9
│   ├── json
│   ├── layer.tar
│   └── VERSION
├── 3b75d6634da4d4f4932d2affeabb7454dc51ba160c3833b386c34e328da8f0ba
│   ├── amq # <<<<< this layer is extracted already, and you can see all the jars here. Other layers are not
│   │   ├── activemq-all-5.11.0.redhat-630495.jar
│   │   ├── bin
│   │   ├── conf
│   │   ├── data
│   │   ├── docs
│   │   ├── examples
│   │   ├── lib
│   │   ├── LICENSE
│   │   ├── NOTICE
│   │   ├── README.txt
│   │   ├── webapps
│   │   └── webapps-demo
│   ├── json
│   ├── layer.tar
│   ├── temp
│   └── VERSION
├── c1fa0e994b2d29f60fd2a6caecbe1ac3f987d001903523d60e532b6e08b094f0
│   ├── json
│   ├── layer.tar
│   └── VERSION
├── c8c84a6c1be5bdfc8caafd23082fd725e84f1c9cddb98fd56cad3a62544b2a3c.json
├── ef5088f89fbac64d2d5982ba14492227f60db1221f6bfd6290c6364a2a95a7e3
│   ├── json
│   ├── layer.tar
│   └── VERSION
├── manifest.json
├── repositories
└── script.sh # <<<<< the script is here
So you ask me why?
Well, did you hear people talking about log4j recently? :) I am doing this right now: log4j vulnerability check: how to quickly detect if log4j is used, in mavevn/in an image? "mvn dependency:tree" does not give a full picture
If someone can tell me how to remove these classes from jib maven plugin, that's better. They are from a base image and I doubt we could do that, though.

Message: Unexpected element '{urn:jboss:domain:keycloak:1.1}subsystem'

I am trying to use keycloak in my app. Im running keycloak on docker and using wildfly 20 as application server. I use this scrypt to start keycloak.
version: '3'
services:
keycloak:
image: quay.io/keycloak/keycloak:10.0.1
container_name: keycloak
environment:
DB_VENDOR: postgres
DB_ADDR: host.docker.internal
DB_USER: keycloak
DB_PASSWORD: test
KEYCLOAK_USER: admin
KEYCLOAK_PASSWORD: test
ports:
- 8079:8080
- 8443:8443
Then I added this snippet to my standalone.xml
<subsystem xmlns="urn:jboss:domain:keycloak:1.1">
<secure-deployment name="pato-ejb.war">
<realm>pato</realm>
<auth-server-url>http://localhost:8079/auth</auth-server-url>
<ssl-required>external</ssl-required>
<resource>pato</resource>
<credential name="secret">password</credential>
</secure-deployment>
</subsystem>
And security settings to my web.xml
<security-constraint>
<web-resource-collection>
<web-resource-name></web-resource-name>
<description>Protects all resources</description>
<url-pattern>*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>admin</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>admin</role-name>
</security-role>
<login-config>
<auth-method>KEYCLOAK</auth-method>
<realm-name>pato</realm-name>
</login-config>
<security-constraint>
<web-resource-collection>
<web-resource-name>user/</web-resource-name>
<url-pattern>/user/*</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>user</role-name>
</auth-constraint>
</security-constraint>
<security-role>
<role-name>user</role-name>
</security-role>
And finaly I added keycloak jars to jboss
folder with jars
When I started standalone.bat I immediately got this error
11:41:14,220 ERROR [org.jboss.as.controller] (Controller Boot Thread)
OPVDX001: Validation error in standalone.xml -----------------------------------
|
| 521: </subsystem>
| 522: <subsystem xmlns="urn:jboss:domain:weld:4.0"/>
| 523: <subsystem xmlns="urn:jboss:domain:keycloak:1.1">
| ^^^^ Unexpected element '{urn:jboss:domain:keycloak:1.1}subsystem'
|
| 524: <secure-deployment name="pato-ejb.war">
| 525: <realm>pato</realm>
| 526: <auth-server-url>http://localhost:8079/auth</auth-server-url>
|
| The primary underlying error message was:
| > ParseError at [row,col]:[523,9]
| > Message: Unexpected element '{urn:jboss:domain:keycloak:1.1}subsystem'
|
|-------------------------------------------------------------------------------
11:41:14,223 ERROR [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0055: Caught exception during boot: org.jboss.as.controller.persistence.ConfigurationPersistenceException: WFLYCTL0085: Failed to parse configuration
at org.jboss.as.controller#12.0.1.Final//org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:143)
at org.jboss.as.server#12.0.1.Final//org.jboss.as.server.ServerService.boot(ServerService.java:395)
at org.jboss.as.controller#12.0.1.Final//org.jboss.as.controller.AbstractControllerService$1.run(AbstractControllerService.java:416)
at java.base/java.lang.Thread.run(Thread.java:834)
11:41:14,227 FATAL [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0056: Server boot has failed in an unrecoverable manner; exiting. See previous messages for details.
In the Keycloak Downloads you'll see a section for the "Client Adapters". This is a .zip or.tar.gz file that you extract into the Wildfly directory. While you have the .jar files you need, you're missing all of the module.xml files. Open up the current version and you'll see the files you need. Additionally, there are installation files that make changes to your standalone.xml to enable Keycloak. The current hierarchy looks something like:
.
├── bin
│   ├── adapter-elytron-install.cli
│   ├── adapter-elytron-install-offline.cli
│   ├── adapter-install.cli
│   └── adapter-install-offline.cli
├── docs
│   └── licenses-keycloak
│   ├── licenses.css
│   ├── licenses.html
│   ├── licenses.xml
│   ├── licenses.xsl
│   ├── org.keycloak,keycloak-adapter-core,12.0.1,Apache Software License 2.0.txt
│   ├── org.keycloak,keycloak-adapter-spi,12.0.1,Apache Software License 2.0.txt
│   ├── org.keycloak,keycloak-authz-client,12.0.1,Apache Software License 2.0.txt
│   ├── org.keycloak,keycloak-common,12.0.1,Apache Software License 2.0.txt
│   ├── org.keycloak,keycloak-core,12.0.1,Apache Software License 2.0.txt
│   ├── org.keycloak,keycloak-jboss-adapter-core,12.0.1,Apache Software License 2.0.txt
│   ├── org.keycloak,keycloak-undertow-adapter,12.0.1,Apache Software License 2.0.txt
│   ├── org.keycloak,keycloak-undertow-adapter-spi,12.0.1,Apache Software License 2.0.txt
│   ├── org.keycloak,keycloak-wildfly-adapter,12.0.1,Apache Software License 2.0.txt
│   ├── org.keycloak,keycloak-wildfly-elytron-oidc-adapter,12.0.1,Apache Software License 2.0.txt
│   └── org.keycloak,keycloak-wildfly-subsystem,12.0.1,Apache Software License 2.0.txt
└── modules
└── system
└── add-ons
└── keycloak
└── org
└── keycloak
├── keycloak-adapter-core
│   └── main
│   ├── keycloak-adapter-core-12.0.1.jar
│   └── module.xml
├── keycloak-adapter-spi
│   └── main
│   ├── keycloak-adapter-spi-12.0.1.jar
│   ├── keycloak-undertow-adapter-spi-12.0.1.jar
│   └── module.xml
├── keycloak-adapter-subsystem
│   └── main
│   └── module.xml
├── keycloak-authz-client
│   └── main
│   ├── keycloak-authz-client-12.0.1.jar
│   └── module.xml
├── keycloak-common
│   └── main
│   ├── keycloak-common-12.0.1.jar
│   └── module.xml
├── keycloak-core
│   └── main
│   ├── keycloak-core-12.0.1.jar
│   └── module.xml
├── keycloak-jboss-adapter-core
│   └── main
│   ├── keycloak-jboss-adapter-core-12.0.1.jar
│   └── module.xml
├── keycloak-undertow-adapter
│   └── main
│   ├── keycloak-undertow-adapter-12.0.1.jar
│   └── module.xml
├── keycloak-wildfly-adapter
│   └── main
│   ├── keycloak-wildfly-adapter-12.0.1.jar
│   └── module.xml
├── keycloak-wildfly-elytron-oidc-adapter
│   └── main
│   ├── keycloak-wildfly-elytron-oidc-adapter-12.0.1.jar
│   └── module.xml
└── keycloak-wildfly-subsystem
└── main
├── keycloak-wildfly-subsystem-12.0.1.jar
└── module.xml
I'd encourage you to install Keycloak in a local environment, outside of Docker to get a feel for how this all fits together. These steps walk you through the process but basically you extract the files to the Wildfly home directory and run the appropriate script in the bin directory.

How to change path to public files on Drupal 8?

By default the path to public filesystem is sites/<site-name>/files in a multi-site environment or just sites/default/files for a single site. How can I change it? I need to keep files on a separate docker volume(s).
You can keep the standard folder structure as it is, and use symlinks to actually use a different path (folder, volume, etc) as the real storage.
Here's the folder structure for a Drupal 8 site I have on my local Homestead. Update the paths according to your own structure.
/home/vagrant/Projects/D/Drupal8/
├── ..
├── private_files
├── public_files
│   ├── ctools
│   ├── field
│   │   └── image
│   └── styles
│   ├── large
│   │   └── public
│   │   └── field
│   │   └── image
│   ├── medium
│   │   └── public
│   │   └── field
│   │   └── image
│   └── thumbnail
│   └── public
│   └── field
│   └── image
├── vendor
└── web
├── includes
├── misc
├── modules
├── profiles
├── scripts
├── sites
│   ├── all
│   └── default
│   └── files -> (symlink) /home/vagrant/Projects/D/Drupal8/public_files/
└── themes
First move current public files directory to outside of Drupal root, or anywhere on your file-system:
$ mv web/sites/default/files public_files
Create a new files directory in its place (Do this only if the next step doesn't work for you):
$ mkdir web/sites/default/files
Create the symlink:
$ ln -s /home/vagrant/Projects/D/Drupal8/public_files/ /home/vagrant/Projects/D/Drupal8/web/sites/default/files
Two important points to pay attention to:
Always use full paths instead of relative paths when creating symbolic links.
Notice the trailing forward-slash usage in source and destination.

Why docker ADD destroys folder structure?

I have the following folder structure:
> tree -L 3
├── pom.xml
├── src
│   ├── main
│   │   ├── java
│   │   └── resources
│   └── test
│   ├── groovy
│   └── resources
I tried to build docker image containing those folders together with files using the following Dockerfile:
FROM jamesdbloom/docker-java8-maven
USER root
RUN mkdir src
ADD ./src/* ./src/
ADD pom.xm
However, the structure in docker image is different. Particularly, I can no longer find main and test folders.
$ tree -L 3
.
├── pom.xml
├── src
│   ├── groovy
│   │   └── com
│   ├── java
│   │   └── com
│   └── resources
│   ├── ext_sample_input.json
│   ├── hist_sample_input.json
│   └── sample_input.json
Why is it so?
From official documentation:
Note: The directory itself is not copied, just its contents.
Change your ADD statement to:
ADD ./src ./src/

My Firefox add-on won't show when I install it

So, I'm utterly and completely new to making Firefox add-ons. I have been trying to make a really, really simple one which will run some JavaScript on the page when I click it. That's literally all I want it to do -_-
However, it will install when I drag it into FF/Nightly, but then not show up in the customise menu. It will say it's installed, but that's it. (I also can't open its preferences, but, I'm really not complaining - I just want a really basic add-on).
If you need the code/entire XPI itself, I'm happy to supply. Thank you :)
I am using the following directories and files:
.
├── chrome
│   ├── chrome.manifest
│   ├── content
│   │   ├── boustrophedonise.js
│   │   ├── browser.xul
│   │   └── prefrences.xul
│   ├── locale
│   │   └── en-UK
│   │   └── translations.dtd
│   └── skin
│   ├── icon.png
│   └── skin.css
├── defaults
│   └── preferences
│   └── pref.js
└── install.rdf
While there may be other problems, your chrome.manifest file is in the wrong directory. It needs to be in the root directory (the same directory as the install.rdf file). This is covered in both the "Setting Up the Development Environment" and "Create a Chrome Manifest" sections of the Building an extension tutorial on MDN. The first section explains that you should start with a directory structure that looks like:
.
├── chrome
│ └── content
│ └── sample.xul (Much of your content in this directory)
├── chrome.manifest
└── install.rdf
The chrome.manifest file is one of the required files for a Firefox add-on. It defines what URLs like chome://myExtension/content/* point to. In your case, without the chrome.manifest file being in the root directory, the URL in your install.rdf of chrome://boustrophedonise/content/options.xul is invalid and is probably complained about in the Firefox Browser Console when the extension is installed (or perhaps when the add-on manager is displayed, or the link for your add-on options is clicked). Firefox probably also complains about the lack of a chrome.manifest file. Obviously, since Firefox is unable to find the chrome.manifest file it does not apply the overlay onto chrome://browser/content/browser.xul, nor the skin, both of which are defined in that file, which are the things that hook your add-on into Firefox.
So in your case, you need to move the chrome.manifest file such that it is located as:
.
├── chrome
│   ├── content
│   │   ├── boustrophedonise.js
│   │   ├── browser.xul
│   │   └── prefrences.xul
│   ├── locale
│   │   └── en-UK
│   │   └── translations.dtd
│   └── skin
│   ├── icon.png
│   └── skin.css
├── chrome.manifest
├── defaults
│   └── preferences
│   └── pref.js
└── install.rdf

Resources