I'm working with a Java application that integrates log4j. For a new development I would need that instead of generating a file I will generate two, one per country that is accessed from the application web. Both would have the same log records that are found throughout my application.
I configured the configuration using an .xml file:
<!-- Appenders -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="jeveris: %d{dd MMM yyyy HH:mm:ss,SSS} %-5p %c - %m%n" />
</layout>
</appender>
<appender name="One-Console" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="Console.log" />
<param name="Append" value="true" />
<param name="MaxFileSize" value="2MB" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern"
value="%d{dd MMM yyyy HH:mm:ss,SSS} %-5p %c - %m%n" />
</layout>
</appender>
<category name="com.example.one.web">
<level value="debug" />
<appender-ref ref="One-Console" />
</category>
<root>
<appender-ref ref="console" />
<level value="debug" />
</root>
</log4j:configuration>
Could someone guide me, tell me if it is possible or help me find the solution?
Thank you.
If you want 2+ log files that will print the same content, then you could fine 2 different files in your tag like so:
<configuration status="OFF">
<Properties>
<Property name="log-path">/your/file/path/</Property>
<Property name="log-country-name1">Country1</Property>
<Property name="log-country-name2">Country2</Property>
<!-- more if necessary -->
<Property name="log-pattern">%d{ISO8601} %-5p [%t|%c{1}] %m\n</Property>
<Property name="rollover-strategy-max">5</Property>
<Property name="rolling-size-based">10 MB</Property>
</Properties>
<appenders>
<!--uncomment following if want to print to console as well -->
<!-- <Console name="Console" target="SYSTEM_OUT">
<PatternLayout>
<pattern>${log-pattern}</pattern>
</PatternLayout>
</Console> -->
<RollingFile name="INFO" fileName="${log-path}/${log-country-name1}-logger.log" filePattern="${log-path}/${log-project-name}-debug-%d-%i.log.zip">
<PatternLayout>
<pattern>${log-pattern}</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="${rolling-size-based}" />
</Policies>
<DefaultRolloverStrategy max="${rollover-strategy-max}" />
</RollingFile>
<RollingFile name="INFO" fileName="${log-path}/UpdaterLocal-logger.log" filePattern="${log-path}/${log-country-name2}-debug-%d-%i.log.zip">
<PatternLayout>
<pattern>${log-pattern}</pattern>
</PatternLayout>
<Policies>
<SizeBasedTriggeringPolicy size="${rolling-size-based}" />
</Policies>
<DefaultRolloverStrategy max="${rollover-strategy-max}" />
</RollingFile>
</appenders>
<Loggers>
<logger name="io.switchfour" level="trace" additivity="false">
<AppenderRef ref="INFO" level="info" />
</logger>
</Loggers>
The above will create /your/file/path/Country1-logger.log and /your/file/path/Country2-logger.log and will write all entries that are INFO or higher to both files. Your log file should be identical.
Related
I did the configuration for storing the message in SQL Server according to the examples that were in the internet.
Tables are created when ActiveMQ is executed, but when I create and send messages via localhost:8161/admin/queues.jsp a record is not inserted into the database table ACTIVEMQ_MSGS.
I tested the changes that were possible, and I saw some things on the internet. I applied them in the config file, but it didn't work.
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.conf}/credentials.properties</value>
</property>
</bean>
<!-- Allows accessing the server log -->
<bean id="logQuery" class="io.fabric8.insight.log.log4j.Log4jLogQuery" lazy-init="false" scope="singleton" init-method="start" destroy-method="stop" />
<bean id="mssql-ds" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="url" value="jdbc:sqlserver://localhost:1433;DatabaseName=activedb" />
<property name="username" value="username" />
<property name="password" value="password" />
<property name="poolPreparedStatements" value="true" />
</bean>
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost">
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry topic=">" producerFlowControl="true">
<pendingMessageLimitStrategy>
<constantPendingMessageLimitStrategy limit="1000" />
</pendingMessageLimitStrategy>
</policyEntry>
<policyEntry queue=">" producerFlowControl="true" memoryLimit="1mb" />
</policyEntries>
</policyMap>
</destinationPolicy>
<managementContext>
<managementContext createConnector="false" />
</managementContext>
<persistenceAdapter>
<jdbcPersistenceAdapter dataDirectory="${activemq.data}" dataSource="#mssql-ds" lockKeepAlivePeriod="0">
<adapter>
<transact-jdbc-adapter />
</adapter>
<locker>
<lease-database-locker lockAcquireSleepInterval="10000" dataSource="#mssql-ds">
<statements>
<statements lockTableName="activemq_lock" />
</statements>
</lease-database-locker>
</locker>
</jdbcPersistenceAdapter>
</persistenceAdapter>
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage limit="64 mb" />
</memoryUsage>
<storeUsage>
<storeUsage limit="100 gb" />
</storeUsage>
<tempUsage>
<tempUsage limit="50 gb" />
</tempUsage>
</systemUsage>
</systemUsage>
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:0?maximumConnections=1000" />
</transportConnectors>
<shutdownHooks>
<bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" />
</shutdownHooks>
</broker>
<import resource="jetty.xml" />
</beans>
Ensure you check the "Persistent Delivery" check-box when you send the message via the web console.
We are using ServiceMix 7.0.0.M3 and use the CXF WADL generator.
Now the generated WADL does not seem to have a 'id' attribute in the resource>method tags. For example, the 4th line in the following WADL does not have an 'id' attribute.
<resources base="http://localhost:8181/api/rest/box">
<resource path="/">
<resource path="boxes">
<method name="GET">
<request>
<param name="language" style="header" type="xs:string"/>
<param name="includeInactive" style="query" type="xs:boolean"/>
</request>
<response>
<representation mediaType="application/json;charset=utf-8" element="prefix1:BoxRestResponse"/>
</response>
</method>
</resource>
If I would have the WADL generated with Jersey, I would get an 'id' property, containing the name of the corresponding Java method.
<resources base="http://localhost:8181/api/rest/box">
<resource path="/">
<resource path="boxes">
<method name="GET" id="getBoxes">
<request>
<param name="language" style="header" type="xs:string"/>
<param name="includeInactive" style="query" type="xs:boolean"/>
</request>
<response>
<representation mediaType="application/json;charset=utf-8" element="prefix1:BoxRestResponse"/>
</response>
</method>
</resource>
One of our frontend development tools expects the 'id' attribute to be present.
Is it possible to configure the CXF WADL generator to include the method id attribute?
I found it. The id's are generated when adding the WadlGenerator configuration property 'addResourceAndMethodIds' to the CXF Blueprint file:
<bean id="wadlGenerator" class="org.apache.cxf.jaxrs.model.wadl.WadlGenerator">
<!-- properties: Method Summaries # https://cxf.apache.org/javadoc/latest/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.html -->
<property name="linkJsonToXmlSchema" value="true" />
<property name="useJaxbContextForQnames" value="true" />
<property name="addResourceAndMethodIds" value="true" />
</bean>
Have implemented a CXF client using WSDL which already has WS-SecurityPolicy defined within it . It is working fine otherwise and is used by a web application heavily.
But we observed in perf env that intermittently multiple wsse:Security header is getting added to the SOAP header resulting in failure. It is intermittent and not able to reproduce it in dev environment.
Here is the client configuration:
<jaxws:client
xmlns:tns="http://ws.soa.com/service/XYZ/XYZService/"
name="XYZPort" address="${XYZService.endPoint}"
serviceClass="com.soa.ws.service.XYZ.XYZService.XYZPortType"
serviceName="tns:XYZService">
<jaxws:properties>
<entry key="ws-security.username" value="${XYZService.auth.username}" />
<entry key="ws-security.callback-handler" value-ref="XYZServicePasswordCallback" />
</jaxws:properties>
<jaxws:inInterceptors>
<ref bean="logInBound" />
<ref bean="XYZServiceSOAPResponseInterceptor" />
</jaxws:inInterceptors>
<jaxws:outInterceptors>
<ref bean="logOutBound" />
<ref bean="XYZServiceSOAPRequestInterceptor" />
</jaxws:outInterceptors>
</jaxws:client>
<bean id="XYZServicePasswordCallback" class="com.services.client.XYZ.XYZServiceClientPasswordCallback" >
<property name="username" value="${XYZService.auth.username}" />
<property name="password" value="${XYZService.auth.password}" />
<!-- Decrypt key defined in keyfile.properties -->
<property name="secretKey" value="${key}" />
</bean>
Here is the Intermitttent issue. Security header added twice
<soap:Header>
<wsse:Security soap:mustUnderstand="1" xmlns:wsse="http://docs.oasis- open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-33466425961" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>test</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">XYZPwd</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
<wsse:Security soap:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken wsu:Id="UsernameToken-33466425962" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsse:Username>test</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">XYZPwd</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
I pass a filename to ant script via
ant -Dfilepath=/foo/bar/foobar.suffix
I want to copy it to a destination and if it is a .js file generate a compiled version of it.
This works but currently the compile task runs on all files not just .js file.
How do I exclude non .js files in the "runjscompile" task?
In a fileset I would do this (but I don't get how to apply this on the task):
<fileset dir="${foo}" casesensitive="yes">
<exclude name="**/*.min.js" />
<include name="**/*.js" />
</fileset>
My build.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project name="test" basedir="." default="build">
<taskdef name="jscomp" classname="com.google.javascript.jscomp.ant.CompileTask" classpath="/home/bar/bin/compiler.jar" />
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="/usr/share/java/ant-contrib.jar" />
</classpath>
</taskdef>
<property name="serverRoot" value="/home/bar/server/public_html" />
<property name="foo" value="${serverRoot}/foo/" />
<property name="workspaceRoot"
value="/home/bar/Zend/workspaces/DefaultWorkspace/" />
<property name="foo_service" value="${workspaceRoot}/foo_service/" />
<property name="filepath" value="${filepath}" />
<target name="build" depends="transferFile, runjscompile" />
<target name="transferFile" description="overwrite old file">
<basename property="filename" file="${filepath}" />
<dirname property="path" file="${filepath}" />
<pathconvert property="path.fragment" pathsep="${line.separator}">
<propertyresource name="path" />
<mapper type="regexp" from="^/[^/]+/(.*)" to="\1" />
</pathconvert>
<echo message="copy ${workspaceRoot}${filepath} to ${foo}${path.fragment}${filename}" />
<copy file="${workspaceRoot}${filepath}" tofile="${foo}${path.fragment}${filename}"
overwrite="true" force="true" />
<property name="destFile" value="${foo}${path.fragment}${filename}" />
</target>
<target name="runjscompile">
<echo message="compile ${destFile}" />
<basename property="file" file="${destFile}" />
<basename property="prefix" file="${destFile}" suffix=".js" />
<dirname property="directory" file="${destFile}" />
<echo message="Compressing file ${file} to ${directory}/${prefix}.min.js" />
<jscomp compilationLevel="simple" debug="false" output="${directory}/${prefix}.min.js" forceRecompile="true">
<sources dir="${directory}">
<file name="${file}" />
</sources>
</jscomp>
</target>
</project>
Add another target which checks the file suffix with a <condition> and sets a property if it matches, then make the jscompile target conditional on that. Following your fileset example you probably want something like:
<target name="check.js">
<condition property="do.jscompile">
<!-- check for filepath that ends .js but not .min.js -->
<matches string="${filepath}" pattern=".*(?<!\.min)\.js$$" />
</condition>
</target>
<target name="build" depends="check.js, transferFile, runjscompile" />
<target name="runjscompile" if="do.jscompile">
Ok, so this is a somewhat complicated question, but hopefully somebody can help me out. I created a .bat file to help with batch process data uploads to SalesForce servers. I then tied excel macros to the .bat files by having the .bat files called in Excel VBA.
Here's my problem: Whenever the .bat files are called in VBA, the .log file isn't saved - it's not even executed (almost like the line of code didn't exist in the .bat file).
Now here's the weird part: if I just click on the .bat file to begin the upload process -- as opposed to calling the .bat from within VBA -- the .log file is overwritten and a new one is created.
How can I get the .bat file to save a .log regardless of whether its fired simply by clicking on the .bat file, or from within VBA? This is very frustrating - any and all help is greatly appreciated. Thank you.
Here's my MS-DOS (batch) code:
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org /dtd/spring-beans.dtd">
<beans>
<bean id="Update_Listing_Val_FNMA" class="com.salesforce.dataloader.process.ProcessRunner" singleton="false">
<description>Created by Dataloader Cliq.</description>
<property name="name" value="Update_Listing_Val_FNMA"/>
<property name="configOverrideMap">
<map>
<entry key="dataAccess.name" value="M:\My Folder\CSV Files\salesforce.com\Apex Data Loader 22.0\cliq_process\Update_Listing_Val_FNMA\read\Update_Listing_Val_FNMA.csv"/>
<entry key="dataAccess.readUTF8" value="true"/>
<entry key="dataAccess.type" value="csvRead"/>
<entry key="dataAccess.writeUTF8" value="true"/>
<entry key="process.enableExtractStatusOutput" value="true"/>
<entry key="process.enableLastRunOutput" value="true"/>
<entry key="process.lastRunOutputDirectory" value="M:\My Folder\CSV Files\salesforce.com\Apex Data Loader 22.0\cliq_process\Update_Listing_Val_FNMA\log"/>
<entry key="process.mappingFile" value="M:\My Folder\CSV Files\salesforce.com\Apex Data Loader 22.0\cliq_process\Update_Listing_Val_FNMA\config\Update_Listing_Val_FNMA.sdl"/>
<entry key="process.operation" value="update"/>
<entry key="process.statusOutputDirectory" value="M:\My Folder\CSV Files\salesforce.com\Apex Data Loader 22.0\cliq_process\Update_Listing_Val_FNMA\log"/>
<entry key="sfdc.bulkApiCheckStatusInterval" value="5000"/>
<entry key="sfdc.bulkApiSerialMode" value="5000"/>
<entry key="sfdc.debugMessages" value="false"/>
<entry key="sfdc.enableRetries" value="true"/>
<entry key="sfdc.endpoint" value="https://www.salesforce.com/services/Soap/u/22.0"/>
<entry key="sfdc.entity" value="QA_FNMA__c"/>
<entry key="sfdc.extractionRequestSize" value="500"/>
<entry key="sfdc.insertNulls" value="false"/>
<entry key="sfdc.loadBatchSize" value="100"/>
<entry key="sfdc.maxRetries" value="3"/>
<entry key="sfdc.minRetrySleepSecs" value="2"/>
<entry key="sfdc.noCompression" value="false"/>
<entry key="sfdc.password" value="XXXXXXXXXXXXXXXXXX"/>
<entry key="sfdc.proxyHost" value=""/>
<entry key="sfdc.proxyNtlmDomain" value=""/>
<entry key="sfdc.proxyPassword" value=""/>
<entry key="sfdc.proxyPort" value=""/>
<entry key="sfdc.proxyUsername" value=""/>
<entry key="sfdc.timeoutSecs" value="60"/>
<entry key="sfdc.useBulkApi" value="false"/>
<entry key="sfdc.username" value="XXXXXXXXXXXXXXXXXX"/>
</map>
</property>
</bean>
</beans>
** EDIT - 2/13/14 1649 **
Here's the call from VBA part:
Shell "M:\My Folder\XXXXXXXXXXXX\CSV Files\salesforce.com\Apex Data Loader 22.0\cliq_process\O PKG Status\Update_O_PKG_Status_REAC\Update_O_PKG_Status_REAC.bat"
Application.Wait (Now + TimeValue("0:00:12"))
Sheets("sheet5").Select
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:="M:\My Folder\XXXXXXXXXXXXXXX\CSV Files\salesforce.com\Apex Data Loader 22.0\cliq_process\O PKG Status\Update_O_PKG_Status_FNMA_Reactive\read\Update_O_PKG_Status_FNMA_Reactive", FileFormat:=xlCSV
newFileName = "FREAC O Pkg" & Format(Now, " MM-DD HHMM") & ".csv"
** EDIT - 2/18/14 1221 **
Here's the log-conf file; it's an XML doc.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration>
<appender name="fileAppender" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="log/sdl.log" />
<param name="Append" value="true" />
<param name="MaxFileSize" value="100KB" />
<param name="MaxBackupIndex" value="1" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] %C{2} %M (%F:%L) - %m%n"/>
</layout>
</appender>
<appender name="STDOUT" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p [%t] %C{2} %M (%F:%L) - %m%n"/>
</layout>
</appender>
<category name="org.apache.log4j.xml">
<priority value="warn" />
<appender-ref ref="fileAppender" />
<appender-ref ref="STDOUT" />
</category>
<logger name="org.apache" >
<level value ="warn" />
</logger>
<root>
<priority value ="info" />
<appender-ref ref="fileAppender" />
<appender-ref ref="STDOUT" />
</root>
</log4j:configuration>
** EDIT - 2/19/14 1226 **
Here's the actual .batch file that is calling everything;
SET DLPATH="M:\My Folder\XXXXXXXXXXXXXXXXX\CSV Files\salesforce.com\Apex Data Loader 22.0"
SET DLCONF="M:\My Folder\XXXXXXXXXXXXXXXXX\CSV Files\salesforce.com\Apex Data Loader 22.0\cliq_process\Update_Listing_Val_FNMA\config"
SET DLDATA="M:\My Folder\XXXXXXXXXXXXXXXXX\CSV Files\salesforce.com\Apex Data Loader 22.0\cliq_process\Update_Listing_Val_FNMA\write"
call %DLPATH%\_jvm\bin\java.exe -cp %DLPATH%\DataLoader.jar -Dsalesforce.config.dir=%DLCONF% com.salesforce.dataloader.process.ProcessRunner process.name=Update_Listing_Val_FNMA
REM To rotate your export files, uncomment the line below
REM copy %DLDATA%\Update_Listing_Val_FNMA.csv %DLDATA%\%date:~10,4%%date:~7,2%%date:~4,2%-%time:~0,2%-Update_Listing_Val_FNMA.csv