Skip to content

Commit

Permalink
Merge pull request #3 from jfdenise/port-to-glow
Browse files Browse the repository at this point in the history
Fix logging qs to work with openshift profile
  • Loading branch information
kabir authored Jan 4, 2024
2 parents 55c0a91 + 5def584 commit 3fdbf9a
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
3 changes: 2 additions & 1 deletion logging/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ Now you have deployed the quickstart with the default configuration, you run a m


. Review the `configure-logging.cli` file in the root of this quickstart directory. This script configures the logging subsystem in the server configuration file. It configures the file handlers, creates the logger for our quickstart and sets the level to TRACE. It also assigns the handlers for our quickstart to our logger.
. The CLI script references the logging formatter with the property `${formatter}`. On bare-metal this formatter is named `PATTERN`, on OpenShift it is named `OPENSHIFT`. A properties file is to be provided when executing the CLI to resolve the `formatter` property according to the execution context. The file `cli.properties` is to be used when executing the script on bare-metal. `cli-openshift.properties` is to be used when executing the script on OpenShift.
. Open a new terminal, navigate to the root directory of this quickstart, and run the following command, replacing `__{jbossHomeName}__` with the path to your server:
+
[source,subs="+quotes,attributes+",options="nowrap"]
----
$ __{jbossHomeName}__/bin/jboss-cli.sh --connect --file=configure-logging.cli
$ __{jbossHomeName}__/bin/jboss-cli.sh --connect --file=configure-logging.cli --resolve-parameter-values=true --properties=cli.properties
----
+
NOTE: For Windows, use the `__{jbossHomeName}__\bin\jboss-cli.bat` script.
Expand Down
1 change: 1 addition & 0 deletions logging/cli-openshift.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
formatter=OPENSHIFT
1 change: 1 addition & 0 deletions logging/cli.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
formatter=PATTERN
12 changes: 6 additions & 6 deletions logging/configure-logging.cli
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Add the periodic rotating file handlers corresponding to those added to the logging properties file
/subsystem=logging/file-handler=FILE_QS_TRACE:add(append=false, level=TRACE, named-formatter=PATTERN, file={"path"=>"quickstart-trace.log", "relative-to"=>"jboss.server.log.dir"})
/subsystem=logging/file-handler=FILE_QS_DEBUG:add(append=false, level=DEBUG, named-formatter=PATTERN, file={"path"=>"quickstart-debug.log", "relative-to"=>"jboss.server.log.dir"})
/subsystem=logging/file-handler=FILE_QS_INFO:add(append=false, level=INFO, named-formatter=PATTERN, file={"path"=>"quickstart-info.log", "relative-to"=>"jboss.server.log.dir"})
/subsystem=logging/file-handler=FILE_QS_WARN:add(append=false, level=WARN, named-formatter=PATTERN, file={"path"=>"quickstart-warn.log", "relative-to"=>"jboss.server.log.dir"})
/subsystem=logging/file-handler=FILE_QS_ERROR:add(append=false, level=ERROR, named-formatter=PATTERN, file={"path"=>"quickstart-error.log", "relative-to"=>"jboss.server.log.dir"})
/subsystem=logging/file-handler=FILE_QS_FATAL:add(append=false, level=FATAL, named-formatter=PATTERN, file={"path"=>"quickstart-fatal.log", "relative-to"=>"jboss.server.log.dir"})
/subsystem=logging/file-handler=FILE_QS_TRACE:add(append=false, level=TRACE, named-formatter=${formatter}, file={"path"=>"quickstart-trace.log", "relative-to"=>"jboss.server.log.dir"})
/subsystem=logging/file-handler=FILE_QS_DEBUG:add(append=false, level=DEBUG, named-formatter=${formatter}, file={"path"=>"quickstart-debug.log", "relative-to"=>"jboss.server.log.dir"})
/subsystem=logging/file-handler=FILE_QS_INFO:add(append=false, level=INFO, named-formatter=${formatter}, file={"path"=>"quickstart-info.log", "relative-to"=>"jboss.server.log.dir"})
/subsystem=logging/file-handler=FILE_QS_WARN:add(append=false, level=WARN, named-formatter=${formatter}, file={"path"=>"quickstart-warn.log", "relative-to"=>"jboss.server.log.dir"})
/subsystem=logging/file-handler=FILE_QS_ERROR:add(append=false, level=ERROR, named-formatter=${formatter}, file={"path"=>"quickstart-error.log", "relative-to"=>"jboss.server.log.dir"})
/subsystem=logging/file-handler=FILE_QS_FATAL:add(append=false, level=FATAL, named-formatter=${formatter}, file={"path"=>"quickstart-fatal.log", "relative-to"=>"jboss.server.log.dir"})

# Create the logger for our quickstart class and assign the handlers
/subsystem=logging/logger=org.jboss.as.quickstarts.logging:add(handlers=[FILE_QS_TRACE,FILE_QS_DEBUG,FILE_QS_INFO,FILE_QS_WARN,FILE_QS_ERROR,FILE_QS_FATAL])
Expand Down
14 changes: 9 additions & 5 deletions logging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@
<scripts>
<script>${project.basedir}${file.separator}configure-logging.cli</script>
</scripts>
<!-- Expressions resolved during server execution -->
<resolve-expressions>false</resolve-expressions>
<propertiesFiles>
<file>${project.basedir}${file.separator}cli.properties</file>
</propertiesFiles>
<resolve-expressions>true</resolve-expressions>
</packaging-script>
</packaging-scripts>
</configuration>
Expand All @@ -200,7 +202,7 @@
<version>${version.plugin.wildfly}</version>
<configuration>
<!-- deploys the quickstart on root web context -->
<name>ROOT.war</name>
<filename>ROOT.war</filename>
<discover-provisioning-info>
<version>${version.server}</version>
<context>cloud</context>
Expand All @@ -211,8 +213,10 @@
<scripts>
<script>${project.basedir}${file.separator}configure-logging.cli</script>
</scripts>
<!-- Expressions resolved during server execution -->
<resolve-expressions>false</resolve-expressions>
<propertiesFiles>
<file>${project.basedir}${file.separator}cli-openshift.properties</file>
</propertiesFiles>
<resolve-expressions>true</resolve-expressions>
</packaging-script>
</packaging-scripts>
</configuration>
Expand Down

0 comments on commit 3fdbf9a

Please sign in to comment.