How to configure log4j.properties for embedded Jetty server? - log4j

Currently working with a web page built to use the embedded Jetty server and unable to modify the code to turn on tracing.
As a result, turning on the tracing is being attempted via log4j.properties but unable to obtain any trace information.
Here is the error attempting to be traced. (Error occurs within : JspServletWrapper)
org.apache.jasper.JasperException: java.lang.ClassNotFoundException: org.apache.jsp.index_jsp+
at org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:197)+
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:413)+
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:386)+
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:330)+
at org.eclipse.jetty.jsp.JettyJspServlet.service(JettyJspServlet.java:106)+
JETTY_PATH = /usr/jetty_home
In the JETTY_PATH directory, the log4j.properties was created and since the error occurs within the JsServletWrapper, the file contains the following :
Note : Had to use an example from https://howtodoinjava.com/log4j/how-to-configure-log4j-using-properties-file/ as I haven't previously configured this type of file.
log4j.rootLogger=DEBUG, filer
log4j.appender.filer=org.apache.log4j.FileAppender
log4j.appender.filer.layout=org.apache.log4j.PatternLayout
log4j.appender.filer.layout.ConversionPattern=[%d] %p %c - %m%n
log4j.appender.filer.File=/tmp/tmp/jetty.log
log4j.appender.filer.append=true
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=5
log4j.logger.org.apache.jasper.servlet.JspServletWrapper=DEBUG, filer <----Class attempting to trace
Is the log4j.properties file valid and/or in the correct location?
Is there some other configuration step that required to obtain tracing via the log4j.properties for an embedded Jetty server?
Edited to add the Juli stuff.
The logging.properties is placed in the $JETTY_PATH (not sure if correct location)
cat logging.properties
handlers = 1catalina.org.apache.juli.FileHandler, 2localhost.org.apache.juli.FileHandler, 3manager.org.apache.juli.FileHandler, 4admin.org.apache.juli.FileHandler, 5host-manager.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
.handlers = 1catalina.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################
1catalina.org.apache.juli.FileHandler.level = FINE
1catalina.org.apache.juli.FileHandler.directory = /tmp/tmp/logs
1catalina.org.apache.juli.FileHandler.prefix = catalina.
2localhost.org.apache.juli.FileHandler.level = FINE
2localhost.org.apache.juli.FileHandler.directory = /tmp/tmp/logs
2localhost.org.apache.juli.FileHandler.prefix = localhost.
3manager.org.apache.juli.FileHandler.level = FINE
3manager.org.apache.juli.FileHandler.directory = /tmp/tmp/logs
3manager.org.apache.juli.FileHandler.prefix = manager.
4admin.org.apache.juli.FileHandler.level = FINE
4admin.org.apache.juli.FileHandler.directory = /tmp/tmp/logs
4admin.org.apache.juli.FileHandler.prefix = admin.
5host-manager.org.apache.juli.FileHandler.level = FINE
5host-manager.org.apache.juli.FileHandler.directory = /tmp/tmp/logs
5host-manager.org.apache.juli.FileHandler.prefix = host-manager.
java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.FileHandler
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.FileHandler
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/admin].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/admin].handlers = 4admin.org.apache.juli.FileHandler
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 5host-manager.org.apache.juli.FileHandler
org.apache.jasper.servlet.JspServletWrapper = FINE <-----Class attempting to trace.

Related

Does log4j2.properties file support parameters

Currently we use property.basePath = ${spark.yarn.app.container.log.dir}
We have use case where we are thinking to use common log42.properties file. Wanted to know if there is support to pass app_name as a parameter/argument to be replaced in the log4j2.properties file
Sample lines in log4j2properties file:
appender.console.type = Console
appender.console.name = consoleLogger
logger.app.name = ${appName}
logger.app.appenderRef.console.ref = consoleLogger

Why log4j2 not rolling over after reaching the max and keeps overwriting the default log file?

I am using the below configuration to generate the log rolling based on size. The logs are created, however the rolling stops after creating the max files (10). The default file is keep on overwriting and all the rolled over files never gets updated.
appender.sample.type = RollingFile
appender.sample.name = SampleRollingFile
appender.sample.fileName = ${basedir}/logs/${machine}_My_Sample.0.log
appender.sample.filePattern = ${basedir}/logs/${machine}_My_Sample.%i.log
appender.sample.layout.type = PatternLayout
appender.sample.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p [T:%T] %c{1}:%L - %m%n
appender.sample.policies.type = Policies
appender.sample.policies.size.type = SizeBasedTriggeringPolicy
appender.sample.policies.size.size = 100MB
appender.sample.strategy.type = DefaultRolloverStrategy
appender.sample.strategy.max = 10
But when I changed my default initial file name to My_Sample.log (removing the .0 index) it works perfectly fine. My application requirement is initial file with .0 and the rolling the logs from 1 to 10.
I added the below properties to get the desired result. By enabling tracing (status = TRACE) in the log4j2 they use the index 0 to play around with the renaming and purge. To avoid the collision, I started the index from 1 and the continuous rolling is happening !!
appender.sample.strategy.fileIndex = 1
appender.sample.strategy.min = 1

How to use dcmtk/dcmprscp in Windows

How can I use dcmprscp to receive from SCU Printer a DICOM file and save it, I'm using dcmtk 3.6 & I've some trouble to use it with the default help, this's what I'm doing in CMD:
dcmprscp.exe --config dcmpstat.cfg --printer PRINT2FILE
each time I receive this messagebut (database\index.da) don't exsist in windows
W: $dcmtk: dcmprscp v3.6.0 2011-01-06 $
W: 2016-02-21 00:08:09
W: started
E: database\index.dat: No such file or directory
F: Unable to access database 'database'
I try to follow some tip, but the same result :
http://www.programmershare.com/2468333/
http://www.programmershare.com/3020601/
and this's my printer's PRINT2FILE config :
[PRINT2FILE]
hostname = localhost
type = LOCALPRINTER
description = PRINT2FILE
port = 20006
aetitle = PRINT2FILE
DisableNewVRs = true
FilmDestination = MAGAZINE\PROCESSOR\BIN_1\BIN_2
SupportsPresentationLUT = true
PresentationLUTinFilmSession = true
PresentationLUTMatchRequired = true
PresentationLUTPreferSCPRendering = false
SupportsImageSize = true
SmoothingType = 0\1\2\3\4\5\6\7\8\9\10\11\12\13\14\15
BorderDensity = BLACK\WHITE\150
EmptyImageDensity = BLACK\WHITE\150
MaxDensity = 320\310\300\290\280\270
MinDensity = 20\25\30\35\40\45\50
Annotation = 2\ANNOTATION
Configuration_1 = PERCEPTION_LUT=OEM001
Configuration_2 = PERCEPTION_LUT=KANAMORI
Configuration_3 = ANNOTATION1=FILE1
Configuration_4 = ANNOTATION1=PATID
Configuration_5 = WINDOW_WIDTH=256\WINDOW_CENTER=128
Supports12Bit = true
SupportsDecimateCrop = false
SupportsTrim = true
DisplayFormat=1,1\2,1\1,2\2,2\3,2\2,3\3,3\4,3\5,3\3,4\4,4\5,4\6,4\3,5\4,5\5,5\6,5\4,6\5,6
FilmSizeID = 8INX10IN\11INX14IN\14INX14IN\14INX17IN
MediumType = PAPER\CLEAR FILM\BLUE FILM
MagnificationType = REPLICATE\BILINEAR\CUBIC
The documentation of the "dcmprscp" tool says:
The dcmprscp utility implements the DICOM Basic Grayscale Print
Management Service Class as SCP. It also supports the optional
Presentation LUT SOP Class. The utility is intended for use within the
DICOMscope viewer.
That means, it is usually not run from the command line (as most of the other DCMTK tools) but started automatically in the background by DICOMscope.
Anyway, I think the error message is clear:
E: database\index.dat: No such file or directory
F: Unable to access database 'database'
Did you check whether there is a subdirectory "database" and whether the "index.dat" file exists in this directory? If you should ask why there is a need for a "database" then please read the next paragraph of the documentation:
The dcmprscp utility accepts print jobs from a remote Print SCU.
It does not create real hardcopies but stores print jobs in the local
DICOMscope database as a set of Stored Print objects (one per page)
and Hardcopy Grayscale images (one per film box N-SET)

Logging to console with Pyramid pshell

In the process of developing a Pyramid web application, I've found it very useful to use the command-line pshell to load the application and interact with various code. However, log statements are not echoed on the console, and I'm not sure why.
For instance, lets say in common.utilities.general I have a function:
import logging
log = logging.getLogger(__name__)
def my_util():
log.debug("Executing utility.")
return "Utility was executed."
Then in my command line:
(pyenv)rook:swap nateford$ pshell src/local.ini
2015-10-08 14:44:01,081 INFO [common.orm.pymongo_core][MainThread] PyMongo Connection to replica set successful: localhost:27017
2015-10-08 14:44:01,082 INFO [common.orm.pymongo_core][MainThread] Connected to Mongo Database = turnhere
Python 3.4.3 (default, Mar 10 2015, 14:53:35)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.56)] on darwin
Type "help" for more information.
Environment:
app The WSGI application.
registry Active Pyramid registry.
request Active request object.
root Root of the default resource tree.
root_factory Default root factory used to create `root`.
>>> from common.utilities.general import my_util
>>> my_util()
'Utility was executed.'
>>>
As you can see, there is no log to the console. I would expect:
>>> from common.utilities.general import my_util
>>> my_util()
[some date/server info][DEBUG]: Executing utility.
'Utility was executed.'
>>>
Here is the (relevant) contents of my local.ini file:
<Various elided application settings>
###
# logging configuration
# http://docs.pylonsproject.org/projects/pyramid/en/1.5-branch/narr/logging.html
###
[loggers]
keys = root, common, webapp, services, sqlalchemy
[handlers]
keys = console, applog
[formatters]
keys = generic
[logger_root]
level = INFO
handlers = console, applog
[logger_common]
level = DEBUG
handlers =
qualname = common
[logger_services]
level = DEBUG
handlers =
qualname = common.services
[logger_webapp]
level = DEBUG
handlers =
qualname = webapp
[logger_sqlalchemy]
level = WARN
handlers =
qualname = sqlalchemy.engine
# "level = INFO" logs SQL queries.
# "level = DEBUG" logs SQL queries and results.
# "level = WARN" logs neither. (Recommended for production systems.)
[handler_console]
class = StreamHandler
args = (sys.stderr,)
level = DEBUG
formatter = generic
[handler_applog]
class = FileHandler
args = (r'%(here)s/log/app.log','a')
level = NOTSET
formatter = generic
[formatter_generic]
format = %(asctime)s %(levelname)-5.5s [%(name)s][%(threadName)s] %(message)s
Your root's logger logging level is set INFO which is higher level than DEBUG which is the level you log your messages with. Changing root's logger level to DEBUG should help.

Eclipse ABAP Development: Cannot Retrieve Connection configuration

I have installed ABAP Development Tools on Eclipse 4.2 and Kubuntu 12.04 64 bit and everything went fine.
When I try to create a new ABAP Project and search for configured SAP Connections on the SAP GUI (I have SAP GUI for Java 7.30 rev 3) Eclipse shows the following error:
"Configuration not found in settings file '/home/dfabbri/.SAPGUI/settings', with include 'null', and message server 'null'"
I verified that file '/home/dfabbri/.SAPGUI/settings' is present and not empty; here is the content:
############################################################
#
# file : /home/dfabbri/.SAPGUI/settings
# created : 08.05.2012 12:42:08 CEST
# encoding: UTF-8
#
############################################################
#logonFrameY = "83"
#logonFrameX = "137"
#GLF_showDetailCol = "1"
#GLF_ColumnState = "0 / 75"
#logonFrame_2_X = "970"
#logonFrame_2_Y = "241"
#frameWidth = "778"
#frameHeight = "900"
#logonFrame_2_Width = "348"
#logonFrame_2_Height = "451"
#lookAndFeelDefault = "Tradeshow"
#propFont = "Roboto Cn"
#fixedFont = "Ubuntu Mono"
#labelFont = "Roboto"
#genFont = "Roboto Cn"
#forceLongWindowTitle = "true"
#showListboxKeyAlways = "true"
#listboxSortByKey = "true"
#overwrite = "false"
Does anyone have any suggestion about this problem?
I tried on a Windows Virtual Machine and everything went fine.
I realize this is a really old question but just in case you still have this issue (I have it on my mac all the time) add the following two entries to the bottom of that settings file:
#INCLUDE = "file:///home/dfabbri/.SAPGUI/connections"
#MESSAGESERVER = "file:///home/dfabbri/.SAPGUI/message_servers"
Then create the two files above in that path (connections should already be there), message_servers can be empty. Hope this helps.

Resources