Recording printout messages into the text file.

Please advice how to organize recording terminal messages which come from different classes into different text files separated by pairs.
For example, this message printed out from 3 different classes:
OpenPositionControl CHFJPY o_pos = 2
 OpenPositionControl CHFJPY l_pos = 1
 OpenPositionControl CHFJPY pos_aval = -1
 DealControl EUR/USD opc9 = false
 DealControl position EUR/USD = 0
 DC_S CHF/JPY  PositionControl position =  0
 DC_S CHF/JPY  PositionControl mopc =  0
 OpenPositionControl CHFJPY o_pos = 2
 OpenPositionControl CHFJPY l_pos = 1
 OpenPositionControl CHFJPY pos_aval = -1

Open in new window

and I want to write all printouts from CHFJPY package classes into the file CHFJPY.txt.  So, I can debag not only last 500 lines but do it at any time after restarting application.
Now, for debagging I need to stop app and try to analyze mixed messages from all pairs.
gbcbrAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
CEHJConnect With a Mentor Commented:
Configure a logging framework:

http://logback.qos.ch/manual/index.html
0
 
CEHJCommented:
You'd be well advised to use a proper logging framework then you can choose from where and to where
0
 
gbcbrAuthor Commented:
@CEHJ
>>You'd be well advised to use a proper logging framework then you can choose from where and to where
I'm just explain what I need as a result.
This is temporary needs, because I can't catch some errors on terminal printouts.
Proper logging will be next professional step.
At the moment I just sort and save printouts to find where is error only.
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
gbcbrAuthor Commented:
Let's say, I restrict max QTY of open position by 1 only and I can't catch why sometimes it ignore flag message.
And I think that easiest and simplest way it's just save printouts somewhere.
0
 
CEHJCommented:
>>Proper logging will be next professional step.

There's a saying in this business: 'Do it right - do it  NOW'

You certainly don't want to put logging in twice. What's more, for your relatively sophisticated needs, that would be a lot of work - it would require partial reinvention of a logging framework
0
 
gbcbrAuthor Commented:
I supposed that this saving it has nothing together with logging, just different kind of printout, not on screen, into the file.
If it need to involve logging framework, first what I need to make program what exactly I need to log, this is the big story.
0
 
CEHJCommented:
Logging frameworks are designed to enable printout to a file or files
0
 
gbcbrAuthor Commented:
As I understood from Wikipedia:
*/The Formatter accepts the message object and formats it for output. The framework then hands the formatted message to the appropriate Appender for disposition. This might include a console display, writing to disk, appending to a database, or email.
System.out.println is the final part of logging which make >> console display << of event, so I suppose it has to be similar like System.out.savetofile
0
 
CEHJCommented:
The destination of logging is controlled by configuration - you don't need to write any code
0
 
gbcbrAuthor Commented:
So, how to log my messages?
0
 
for_yanConnect With a Mentor Commented:

Logging is a possibility, you can use Logger class for that:
http://www.java-tips.org/java-se-tips/java.util.logging/how-to-use-logger.html


Still, if this is temporary, you may do something even simpler.
It does not matter that messages are generated in different classes. You can open
text file in your, so to speak main class, and make a method that would
write the message to that file, where message text would be a String argument of that
method. And then from all you classes you can call this method
and add new message to your file.

 
0
 
gbcbrAuthor Commented:
@for_yan
This is much close to my idea.
I start read tutorial from CEHJ, but for my level it's still very complicated, it need XML files creating and many other things which I never did.
For this way I can create in package CHFJPY class LoggerCHFJPY, instantiate it and call it in parallel with System.out.prinln
Is it correct?
0
 
for_yanCommented:

No, Logger is class which is given to you among core Java classes - part of JDK
0
 
gbcbrAuthor Commented:
OK, but my class is LoggerCHFJPY, that is different. If it's valuable I can change it to LogCHFJPY
0
 
for_yanCommented:
So, somewhere close to the befginning opf our App, say in main method
you insert the part of code you see in this example creating Filehandler (and at the same time naming the file),
Formatter, etc.).

Then when you need to write a message somwhere in other classes you say
 Logger logger = Logger.getLogger("MyLog");
and then put your message
 logger.log(Level.WARNING,"This is my message to log");

This is how I understand it should work.
0
 
for_yanCommented:
So you cannot change the name of the class Logger (this is like the class ArrayList - it is inveneted by  developers of JDK, not you).
You can specify the  log file name in FileHandler - that is true
0
 
gbcbrAuthor Commented:
But in the sample class name is
>>public class MyLogger {
So, I don't think that it valuable.
0
 
CEHJCommented:
If you want something quick and dirty that won't waste your time:


java DDC >logfile.txt

Now any System.out.println will go into that text file
0
 
gbcbrAuthor Commented:
@CEHJ
>>java DDC >logfile.txt
this what I ask from the beginning!
Where I have to place it exactly?
0
 
CEHJCommented:
You don't place it anywhere. It (the file) will be created in the directory from which you run the app
0
 
for_yanCommented:
You do not need the class MyLogger togetehr with its name.
They are given here jaust as an example.
Somewheer say in your main method where you launch your application you put such commands:

  Logger logger = Logger.getLogger("MyLog");
    FileHandler fh;

    try {

      // This block configure the logger with handler and formatter
      fh = new FileHandler("c:\\MyLogFile.log", true);
      logger.addHandler(fh);
      logger.setLevel(Level.ALL);
      SimpleFormatter formatter = new SimpleFormatter();
      fh.setFormatter(formatter);

      } catch (...)

....

}

Then somehwre in the rest of your code you say:

 Logger logger = Logger.getLogger("MyLog");

and then everywhere in the scope of that class where variable logger
is accessible you can record your messages to your log

using such commands:
 logger.log(Level.WARNING,"My first log");

If you then need tio record messages in another class of yours
you again say at the top of your class

Logger logger = Logger.getLogger("MyLog");

and then again can log messages in that class.

Because you refere to the same name of the logger ("MyLog")
all of your messages eventually turn to be in file

c:\\MyLogFile.log

because this file is in FileHandler associated with your logger




 



   
   





0
 
gbcbrAuthor Commented:
@for_yan
But I want to create separated log files for each pair, not one for everybody. If it's CHFJPY.log it has to be only messages from classes which manage this pair only.

@CEHJ
You again confuse me, I don't understand what it means >> java DDC >logfile.txt
I suppose that I have to write some code which initiative copying messages into the file.
0
 
CEHJCommented:
>>I suppose that I have to write some code which initiative copying messages into the file.

No you don't


>> what it means >> java DDC >logfile.txt

java is a programme that runs a Java application
'DCC' is the name of your main class (at least i thought it was)
That's the command you enter at the command line
0
 
for_yanCommented:
If you want to write everything into one file then the simplest thing is what CEHJ suggests - just redirection of the output.

If you want to write to different files then you can use this Logger way to do it.

The way to do it is in the beginning to create two or more loggers each one associated
with its own name and with its owbn file handler and then within your classes open either one
or another or both of them and certain messages to record to one logger and other messages tio anothoer
logger.


Logger logger1 = Logger.getLogger("MyLog1");
Logger logger2 = Logger.getLogger("MyLog2");
    FileHandler fh1;
 FileHandler fh2;


    try {

      // This block configure the logger with handler and formatter
      fh1 = new FileHandler("c:\\MyLogFile1.log", true);
     fh2 = new FileHandler("c:\\MyLogFile2.log", true);

      logger1.addHandler(fh);
      logger1.setLevel(Level.ALL);
      SimpleFormatter formatter = new SimpleFormatter();
      fh1.setFormatter(formatter);

    logger2.addHandler(fh);
      logger2.setLevel(Level.ALL);
      SimpleFormatter formatter = new SimpleFormatter();
      fh2.setFormatter(formatter);


      } catch (...)

....

}

and then wherever you want to og to the first you say


Logger logger1 = Logger.getLogger("MyLog1");

logger1.log(...)

or fgor other messages you say

Logger logger2 = Logger.getLogger("MyLog2");

logger2.log(...)

or you can have them both opned and select by mesages.

All is possible.

Howbever if you want to write to mane separate files it is probably
more logical to open just one file for each class in normal way and write to it
But to have two or three loggers it is still reasonable.








0
 
gbcbrAuthor Commented:
why I can't run it?
iMac-Office:connect gbcbr$ java Main >logfile.txt
Exception in thread "main" java.lang.NoClassDefFoundError: Main
Caused by: java.lang.ClassNotFoundException: Main
	at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
iMac-Office:connect gbcbr$ ls
DBFXConnect.java	PMDS.java		package.html
LionFXConnect.java	SelectData.java
Main.java		logfile.txt
iMac-Office:connect gbcbr$

Open in new window

0
 
CEHJCommented:
You don't have Main.class in that directory
0
 
for_yanCommented:

Is your class which conatins main() method called Main ?

You shiould name the class name not the method name in the java command

0
 
CEHJCommented:
Since you're on a Unix-based system, you have (when you've compiled it or found where Main.class is) you have the benefit of having both types of output. Do instead
java Main | tee logfile.txt

Open in new window

0
 
gbcbrAuthor Commented:
The main class with main method is Main and it's located there
public class Main {

    private static DBFXConnect startup;

    public static void main(String[] args) throws Exception {

        callSelect();

        startup = new DBFXConnect();
        startup.startUp(args);

    }

    private static Timer timer;

    /**
     * @throws Exception
     */
    public static void callSelect() throws Exception {
        try {
            timer = new Timer();
            timer.schedule(new SelectData(), 10000, 1000);
            System.out.println("          switch on the Timer");
            System.out.println("=>");

        } catch (Exception ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

Open in new window

as you can see after ls command above
0
 
CEHJCommented:
>>The main class with main method is Main and it's located there

You've just listed the directory - see below. Main.class is not there. You need to compile Main.java
iMac-Office:connect gbcbr$ ls
DBFXConnect.java	PMDS.java		package.html
LionFXConnect.java	SelectData.java
Main.java		logfile.txt
iMac-Office:connect gbcbr$

Open in new window

0
 
gbcbrAuthor Commented:
how I can compile it if application works? It's already compiled and run.
This is the reason why I can't start it second time
0
 
CEHJCommented:
It can't possibly work by running class files in that directory - because there aren't any
0
 
mrcoffee365Commented:
You won't be able to use for_yan's code until you import a Logger class.  For example:

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
0
 
mrcoffee365Connect With a Mentor Commented:
But CEHJ is right -- use log4j or some other logging package, rather than rolling your own.  Setup is more complicated, but we all have a lot of knowledge about it, so if you ask us for help, it would go very quickly.

For log4j:
1) get the log4j jar here:
http://logging.apache.org/log4j/1.2/download.html
2) put the jar somewhere in your classpath, and add the import to your .java code:
import org.apache.log4j.*;
3) create a file named log4j.properties  and put it in your classpath.  Cut and paste this one as a start:

log4j.rootCategory=DEBUG, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{MM/dd/yy HH:mm:ss} [%c{4}]:(%x):%-5p: %m%n
log4j.appender.stdout.threshold=DEBUG

and then statements in your .java code like this will work:
Logger logger = Logger.getLogger("MyLog");

logger.debug("This is a debugging log message");
0
 
gbcbrAuthor Commented:
@mrcoffee365
>>1) get the log4j jar here:
http://logging.apache.org/log4j/1.2/download.html
this was one of main problem from where to import

I create log4j.properties, import org.apache.log4j.*; and put this code into my statement:
public void decisionCenter_CHFJPY_S(boolean bl9) throws Exception {

        System.out.println(" DC_S CHF/JPY  BusinessLogic =  " + bl9);
        System.out.println(" DC_S CHF/JPY  TradeOpen =  " + mflag9s);
        System.out.println(" DC_S CHF/JPY  BorderControl =  " + mbc);
        System.out.println(" DC_S CHF/JPY  PositionControl =  " + mopc);

        Logger logger = Logger.getLogger("CHFJPY");
        logger.debug( "DC_S CHF/JPY  PositionControl");

Open in new window

but I have error: method debug not found.

Second question is that I need value of mopc which is integer, shall I convert it into the String before logging or I can write String.valueOf(mopc) directly into logger line?
0
 
for_yanCommented:
You can put any string as argument for
logger.debug(s);
So if you want to print integer, the sae way as you do in System.out.println
you can say

logger.debug("" + mopc)

when you concatenate int with String it becomes String already - you may concatenate with
empty string  ("")  and it becomes a String .

Maybe you can write even dierctly mpopc, but I usually concatenate with empty string in such cases


0
 
gbcbrAuthor Commented:
>>logger.debug("" + mopc)
this is good but why it can't find debug method?
0
 
for_yanCommented:
My guess is that you may be using java.util.Logger rather than log4j.Logger
0
 
for_yanCommented:

Make sure thaat you don't have

import java.util.logging.Logger;

somewhere on the top of your code
0
 
for_yanCommented:
You should rather have
import org.apache.log4j.Logger

but not

import java.util.logging.Logger;
0
 
gbcbrAuthor Commented:
Yes, I have it because I have
}
        } catch (Exception ex) {
            Logger.getLogger(DecisionCenter_CHFJPY_S.class.getName()).log(Level.SEVERE,
                                                                          null,
                                                                          ex);
        }

Open in new window

0
 
gbcbrAuthor Commented:
So, now I have conflict between two loggers, how to solve this?
0
 
for_yanCommented:

I don't think you need to use both Logger from Java and Logger from apache - use only one of them.
Anyway, you can write explicitly in yourt code like that:

  org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger("CHFJPY");
        logger.debug( "DC_S CHF/JPY  PositionControl");


0
 
gbcbrAuthor Commented:
In general I don't understand why I need to use logger for catch exception, somebody advice to do this instead of simple printStackTrace, so I just follow this advice. If it's not critical, I can just change it back and remove extra one logger from class
0
 
for_yanCommented:
I'd think that would be  a good idea,
You can use your log4j to get StackTrace also:
http://www.devdaily.com/blog/post/java/how-print-exception-stack-trace-using-log4j-commons
0
 
CEHJCommented:
Since you're not already wedded to a logging system, you should probably go straight to the best one (which ironically will permit you most easily to use another system, since it uses a facacde):

http://logback.qos.ch/reasonsToSwitch.html
0
 
gbcbrAuthor Commented:
I start this logger, but it print on the screen bulk of messages.
I suppose that it will log only what I need.
Of course it's nice to have all this information but:
1. I don't want it on the screen.
2. I need to save in separate place what I ask from logger.
Logger logger9 = Logger.getLogger("CHFJPY");
        
        logger9.debug(" DC_S CHF/JPY  BusinessLogic =  " + bl9);
        logger9.debug(" DC_S CHF/JPY  TradeOpen =  " + mflag9s);
        logger9.debug(" DC_S CHF/JPY  BorderControl =  " + mbc);
        logger9.debug("DC_S CHF/JPY  PositionControl" + mopc);

Open in new window

3. It's no log file at all.

Please advice
0
 
CEHJCommented:
Please post your logging config file
0
 
gbcbrAuthor Commented:
@CEHJ
>>Reasons to prefer logback over log4j
>>If you are already familiar with log4j, you will quickly feel at home using logback.

:-)
0
 
gbcbrAuthor Commented:
You mean log4j.properties?
log4j.rootCategory=DEBUG, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{MM/dd/yy HH:mm:ss} [%c{4}]:(%x):%-5p: %m%n
log4j.appender.stdout.threshold=DEBUG

Open in new window

0
 
CEHJCommented:
Yes. You've only got a ConsoleAppender configured - you need a FileAppender
0
 
CEHJCommented:
Please post your ideal path to the log file and i'll give you a config
0
 
gbcbrAuthor Commented:
I understand this, but I need 10 log files separated by pairs, so I need 10 appenders
0
 
CEHJCommented:
Well let's start with one ;)
0
 
gbcbrAuthor Commented:
Let's place it into scr directory directly, because now I need it with quick access
0
 
CEHJCommented:
Well i don't know where that is, so let's place them in /tmp
.properties files are inferior to xml files, so delete the old config and replace with
<?xml version="1.0" encoding="UTF-8" ?>
<!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
  -->
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

    <!-- ====================================================================== -->
    <!-- A P P E N D E R S                                                      -->
    <!-- ====================================================================== -->

    <!-- console 
    <appender name="console" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* %c{1}: %m (%F, line %L)%n"/>
        </layout>
    </appender>
    -->

    
    <appender name="CHFJPY" class="org.apache.log4j.FileAppender">
	<param name="File" value="/tmp/CHFJPY.log"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d{dd.MM.yyyy HH:mm:ss} *%-5p* %c{1}: %m (%F, line %L)%n"/>
        </layout>
    </appender>
    

    <!-- ====================================================================== -->
    <!-- L O G G E R S                                                          -->
    <!-- ====================================================================== -->

    <root>
        <level value="debug" />
	<!--
	<appender-ref ref="console"/>
	-->
	<appender-ref ref="CHFJPY"/> 
    </root>

</log4j:configuration>

Open in new window

0
 
CEHJCommented:
That file MUST be called log4j.xml
0
 
gbcbrAuthor Commented:
I can't find where are located .xml files, I suppose that I don't have them at all
0
 
gbcbrAuthor Commented:
Error: unable to copy to output directory, log4j.properties not found
0
 
mrcoffee365Commented:
To put a file appender in your log4j.properties file, add this:

log4j.appender.R2=org.apache.log4j.RollingFileAppender
log4j.appender.R2.maxFileSize=100KB
log4j.appender.R2.maxBackupIndex=5
log4j.appender.R2.File=C:/Program Files/Apache Software Foundation/Tomcat6/logs/log4jMyApp.log
log4j.appender.R2.threshold=DEBUG
log4j.appender.R2.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%d{MM/dd/yy HH:mm:ss} [%c{8}]:(%x):%-5p: %m%n

Then add R2 to your log list at the top of log4j.properties:

log4j.rootCategory=DEBUG, stdout, R2

Each of your 10 log files can have a different defined file location.  Or, put a log4j.properties file in the WEB-INF/classes directory of each of your apps, and assign them a different log file name.
0
 
gbcbrAuthor Commented:
@mrcoffee
Now apart of console it create 6 CHFJPY.log files full of log garbage
OFFER;U;37;1-b25e594d-b435-ce79-87af-bb6b1bfd74b1##87USDNOK1S--b9ynoaLQj.2go2sE;;;03252011090313000;5.56743;5.57020;;;;;;;T;T;5.61600;5.52860;25;
OFFER;U;5;Q-EU0094524-EURCHF-237222681;;;03252011090313000;1.29457;1.29482;;;;;;;T;T;1.29537;1.27868;20;
</f></m></fxmsg>
++++++++++++++++++++++++++++++++++++++++

QueueElement( ISessionStatus *) = {ConnectionName}	{Demo}
{StatusCode}	{0}
{StatusMessage}	{Request sent.}
{ProtocolName}	{HTTP}
{StatusMessageID}	{5}
{StatusName}	{Ready}
{SecureProtocolString}	{S}


UpdateProcessorThread. force
Status updated on Client
Parsing:
<fxmsg v="pdas"><m t="U55" q="0"><f n="112">DB_U100D1_4ZQ5UIEmmUvSZUjQCjZSY7iKUpPycTxryQv3SQcc2aZI0XEfXyQqFG-1361</f><f n="SID">DB_U100D1_4ZQ5UIEmmUvSZUjQCjZSY7iKUpPycTxryQv3SQcc2aZI0XEfXyQqFG</f><f n="9028">10</f><f n="35">U55</f><f n="9033">BUS.RR</f><f n="336">FXCM</f><f n="9035">TOPIC.RR.DBFXUSDD1</f><l n="9016"><g><f n="9017">TraderID</f><f n="9018">1070132</f></g><g><f n="9017">DAS</f><f n="9018"><![CDATA[0
17268261;544830398;;;779442;00779442;10;0.8;0;03222011093009;115.533;Force Execute;B;10000;dbd11070132001;Grebnevsky;1;115.533;0;0;100;32;42852135;DB_U100D1_q2SulFScl0nd197zAeAX27qUevxKb6riMv0qMj0TbDfPBqW8z99CDA-99211;EURJPY.AlgoTradeMarket_EURJPY.<init>();100;;;;;1155330;1155330;[FXCM ID,D,3,];
17335608;544830404;;;779442;00779442;12;-0.02;0;03242011153457;89.39;Force Execute;B;10000;dbd11070132001;Grebnevsky;1;89.39;0;0;100;32;43198828;DB_U100D1_ujRcm58x2HxSPvMeOHIvr0GsGlyrOY4RY3mdPpIOdmNWjqp6dwHCOd-5764;CHFJPY.AlgoTradeMarket_CHFJPY.<init>();100;;;;;893900;893900;[FXCM ID,D,3,];
17335555;544830401;;;779442;00779442;12;-0.02;0;03242011153308;89.405;Force Execute;B;10000;dbd11070132001;Grebnevsky;1;89.405;0;0;100;32;43198630;DB_U100D1_ujRcm58x2HxSPvMeOHIvr0GsGlyrOY4RY3mdPpIOdmNWjqp6dwHCOd-5550;CHFJPY.AlgoTradeMarket_CHFJPY.<init>();100;;;;;894050;894050;[FXCM ID,D,3,];
17303081;544830407;;;779442;00779442;12;-0.08;0;03232011125629;89.865;Force Execute;B;10000;dbd11070132001;Grebnevsky;1;89.865;0;0;100;32;42996647;DB_U100D1_jJmc4K4AMXLNhKyCqQGXtA1IAX2bqsFCOECGJTOsKiD0bClqQffGzO-607;CHFJPY.AlgoTradeMarket_CHFJPY.<init>();100;;;;;898650;898650;[FXCM ID,D,3,];
17323712;544830413;;;779442;00779442;13;0.14;0;03242011092036;1.47765;Force Execute;B;10000;dbd11070132001;Grebnevsky;1;1.47765;0;0;100;32;43114373;DB_U100D1_DFhI48mz9YJk4Lwb7sw4d6xQFlXiI6mo86CoEGyBj9pfPiSqnApSjW-106671;GBPCHF.AlgoTradeMarket_GBPCHF.<init>();100;;;;;14776.5;14776.5;[FXCM ID,D,3,];
]]></f></g><g><f n="9017">QID</f><f n="9018">DB_U100D1_4ZQ5UIEmmUvSZUjQCjZSY7iKUpPycTxryQv3SQcc2aZI0XEfXyQqFG-1361</f></g><g><f n="9017">SID</f><f n="9018">DB_U100D1_4ZQ5UIEmmUvSZUjQCjZSY7iKUpPycTxryQv3SQcc2aZI0XEfXyQqFG</f></g><g><f n="9017">AcctReportID</f><f n="9018">all</f></g></l><f n="625">DBFXUSDD1</f><f n="9057">SRV.RR.DBFXUSDD1</f><f n="9032">SRV.RR.DBFXUSDD1.1300539546867</f></m><m t="U55" q="0"><f n="112">DB_U100D1_4ZQ5UIEmmUvSZUjQCjZSY7iKUpPycTxryQv3SQcc2aZI0XEfXyQqFG-1360</f><f n="SID">DB_U100D1_4ZQ5UIEmmUvSZUjQCjZSY7iKUpPycTxryQv3SQcc2aZI0XEfXyQqFG</f><f n="9028">10</f><f n="35">U55</f><f n="9033">BUS.RR</f><f n="336">FXCM</f><f n="9035">TOPIC.RR.DBFXUSDD1</f><l n="9016"><g><f n="9017">TraderID</f><f n="9018">1070132</f></g><g><f n="9017">DAS</f><f n="9018"><![CDATA[0
17268261;544830398;;;779442;00779442;10;0.8;0;03222011093009;115.533;Force Execute;B;10000;dbd11070132001;Grebnevsky;1;115.533;0;0;100;32;42852135;DB_U100D1_q2SulFScl0nd197zAeAX27qUevxKb6riMv0qMj0TbDfPBqW8z99CDA-99211;EURJPY.AlgoTradeMarket_EURJPY.<init>();100;;;;;1155330;1155330;[FXCM ID,D,3,];
17335608;544830404;;;779442;00779442;12;-0.02;0;03242011153457;89.39;Force Execute;B;10000;dbd11070132001;Grebnevsky;1;89.39;0;0;100;32;43198828;DB_U100D1_ujRcm58x2HxSPvMeOHIvr0GsGlyrOY4RY3mdPpIOdmNWjqp6dwHCOd-5764;CHFJPY.AlgoTradeMarket_CHFJPY.<init>();100;;;;;893900;893900;[FXCM ID,D,3,];
17335555;544830401;;;779442;00779442;12;-0.02;0;03242011153308;89.405;Force Execute;B;10000;dbd11070132001;Grebnevsky;1;89.405;0;0;100;32;43198630;DB_U100D1_ujRcm58x2HxSPvMeOHIvr0GsGlyrOY4RY3mdPpIOdmNWjqp6dwHCOd-5550;CHFJPY.AlgoTradeMarket_CHFJPY.<init>();100;;;;;894050;894050;[FXCM ID,D,3,];
17303081;544830407;;;779442;00779442;12;-0.08;0;03232011125629;89.865;Force Execute;B;10000;dbd11070132001;Grebnevsky;1;89.865;0;0;100;32;42996647;DB_U100D1_jJmc4K4AMXLNhKyCqQGXtA1IAX2bqsFCOECGJTOsKiD0bClqQffGzO-607;CHFJPY.AlgoTradeMarket_CHFJPY.<init>();100;;;;;898650;898650;[FXCM ID,D,3,];
17323712;544830413;;;779442;00779442;13;0.14;0;03242011092036;1.47765;Force Execute;B;10000;dbd11070132001;Grebnevsky;1;1.47765;0;0;100;32;43114373;DB_U100D1_DFhI48mz9YJk4Lwb7sw4d6xQFlXiI6mo86CoEGyBj9pfPiSqnApSjW-106671;GBPCHF.AlgoTradeMarket_GBPCHF.<init>();100;;;;;14776.5;14776.5;[FXCM ID,D,3,];
]]></f></g><g><f n="9017">QID</f><f n="9018">DB_U100D1_4ZQ5UIEmmUvSZUjQCjZSY7iKUpPycTxryQv3SQcc2aZI0XEfXyQqFG-1360</f></g><g><f n="9017">SID</f><f n="9018">DB_U100D1_4ZQ5UIEmmUvSZUjQCjZSY7iKUpPycTxryQv3SQcc2aZI0XEfXyQqFG</f></g><g><f n="9017">AcctReportID</f><f n="9018">all</f></g></l><f n="625">DBFXUSDD1</f><f n="9057">SRV.RR.DBFXUSDD1</f><f n="9032">SRV.RR.DBFXUSDD1.1300539546867</f></m><m t="U60" q="0"><f n="9028">0</f><f n="35">U60</f><f n="58">0;03252011090313792;90;0;0;
OFFER;U;9;Q-EU0094524-EURGBP-237222674;;;03252011090313000;0.88022;0.88042;;;;;;;T;T;0.88105;0.86627;11;
OFFER;U;1;Q-EU0094524-EURUSD-237222820;;;03252011090313000;1.41523;1.41540;;;;;;;T;T;1.42219;1.40535;19;
OFFER;U;4;Q-EU0094524-USDCHF-237222678;;;03252011090313000;0.91467;0.91489;;;;;;;T;T;0.91508;0.90286;22;
OFFER;U;3;Q-EU0094524-GBPUSD-237222453;;;03252011090313000;1.60762;1.60784;;;;;;;T;T;1.62681;1.60683;19;
OFFER;U;39;Q-EU0094524-AUDCHF-237223005;;;03252011090313000;0.93465;0.93505;;;;;;;T;T;0.93545;0.91574;25;
OFFER;U;17;28312293460001110325090313163;;;03252011090313000;83.000;83.030;;;;;;;T;T;83.070;81.765;18;
OFFER;U;37;1-b25e594d-b435-ce79-87af-bb6b1bfd74b1##87USDNOK1S--b9ynoaLQj.2go2sE;;;03252011090313000;5.56743;5.57020;;;;;;;T;T;5.61600;5.52860;25;
OFFER;U;5;Q-EU0094524-EURCHF-237222681;;;03252011090313000;1.29457;1.29482;;;;;;;T;T;1.29537;1.27868;20;
</f></m></fxmsg>

Open in new window

except what I need.
How to switch off this garbage and get only one file with minimum asked information?
log.tiff
@CEHJ
When I remove log4j.properties file and place log4j.xml into src directory it stop works at all, what is the proper place for .xml?
0
 
CEHJCommented:
>>When I remove log4j.properties file and place log4j.xml into src directory it stop works at all, what is the proper place for .xml?

The same directory as  log4j.properties was in
0
 
gbcbrAuthor Commented:
I copy it there from the beginning, but you see above error.
It's try to find .properties file and ignore .xml file in the same place
0
 
CEHJCommented:
Please execute this command in the same directory as log4j.properties and print the result here:
ls -l .

Open in new window

0
 
gbcbrAuthor Commented:
iMac-Office:src gbcbr$ ls -l
total 1320
drwxr-xr-x  12 gbcbr  staff     408 Mar 24 19:19 CHFJPY
-rw-r--r--   1 gbcbr  staff   54203 Mar 25 11:22 CHFJPY.log
-rw-r--r--   1 gbcbr  staff  121692 Mar 25 11:22 CHFJPY.log.1
-rw-r--r--   1 gbcbr  staff  102474 Mar 25 11:22 CHFJPY.log.2
-rw-r--r--   1 gbcbr  staff  102638 Mar 25 11:22 CHFJPY.log.3
-rw-r--r--   1 gbcbr  staff  132551 Mar 25 11:22 CHFJPY.log.4
-rw-r--r--   1 gbcbr  staff  102871 Mar 25 11:22 CHFJPY.log.5
drwxr-xr-x  11 gbcbr  staff     374 Mar 20 14:28 EURCHF
drwxr-xr-x  11 gbcbr  staff     374 Mar 20 14:49 EURGBP
drwxr-xr-x  11 gbcbr  staff     374 Mar 20 15:07 EURJPY
drwxr-xr-x   2 gbcbr  staff      68 Mar 10 13:27 EURUS
drwxr-xr-x  13 gbcbr  staff     442 Mar 17 09:46 EURUSD
drwxr-xr-x  11 gbcbr  staff     374 Mar 20 15:29 GBPCHF
drwxr-xr-x  12 gbcbr  staff     408 Mar 20 15:54 GBPJPY
drwxr-xr-x  11 gbcbr  staff     374 Mar 20 16:12 GBPUSD
drwxr-xr-x  11 gbcbr  staff     374 Mar 20 16:43 USDCHF
drwxr-xr-x  11 gbcbr  staff     374 Mar 20 16:43 USDJPY
drwxr-xr-x   4 gbcbr  staff     136 Feb 23 11:15 algo
drwxr-xr-x   8 gbcbr  staff     272 Mar 11 22:01 charts
drwxr-xr-x   9 gbcbr  staff     306 Mar 24 20:03 connect
drwxr-xr-x   9 gbcbr  staff     306 Mar 17 11:39 control
drwxr-xr-x   2 gbcbr  staff      68 Feb 16 16:29 dbfx
-rw-r--r--   1 gbcbr  staff     475 Mar 25 11:22 dcc.properties
-rw-r--r--   1 gbcbr  staff     104 Feb 11 15:04 fxmsg.properties
-rw-r--r--   1 gbcbr  staff   23180 Mar 23 12:18 gui.ser
-rw-r--r--@  1 gbcbr  staff     655 Mar 25 10:56 log4j.properties
-rw-r--r--@  1 gbcbr  staff    2278 Mar 25 10:29 log4j.xml
drwxr-xr-x   6 gbcbr  staff     204 Mar  8 13:38 ohlc

Open in new window

0
 
CEHJCommented:
To avoid any precedence problems, you need to rename either the xml file or the properties file
0
 
gbcbrAuthor Commented:
I don't have both of them in this directory at the same time. I just put them together for listening test. At other time one of them out of app directory. This is not a root of problem, as I post before it looks like logger doesn't see .xml file at all, maybe necessary to show him class path to .xml?
0
 
CEHJCommented:
That directory WOULD have to be in the classpath yes. I assumed it is, since that's where the properties file is
0
 
gbcbrAuthor Commented:
I found another strange thing, when I move .properties file out and comment all calls to logger, logically it has to compile because nobody call properties file. But it still generate the same error:
Error: unable to copy to output directory, log4j.properties not found
0
 
CEHJCommented:
If log4j.xml is present, i don't see what the problem could be. You don't have an old version of log4j do you?
0
 
gbcbrAuthor Commented:
No, I start with it just this morning.
Even I try to compile with both files log4j.xml and log4j.properties placed in src directory - it compiles without problem.
0
 
CEHJCommented:
The presence of config files doesn't affect compilation. What version of log4j is it?
0
 
gbcbrAuthor Commented:
I download this morning from Apache site 1.2.16
0
 
gbcbrAuthor Commented:
Another problem now that I can't stop it, it's like virus, he lives by his own rules.
So, I can't see now my standard debug messages, I only see Niagara of garbage on my screen and I can't stop it.
Without log4j.properties it doesn't compile and with it fill screen with garbage with crazy speed.
0
 
gbcbrAuthor Commented:
It's really virus!
I've remove log4j-1.2.16.jar from library and delete everything regarding to it but it still send me error:
Error: unable to copy to output directory, log4j.properties not found
0
 
gbcbrAuthor Commented:
only after deleting everything and restarting jdeveloper it's disappear.
0
 
gbcbrAuthor Commented:
After restarting I put log4j.xml, load again api and start.
It is not ask about properties file, compile well, but result the same:
full screen of garbage, despite that ConsoleAppender commented and 6 log files with garbage.
0
 
gbcbrAuthor Commented:
Even when I delete xml file and start again it continue this s..t without any configuration file it the system.
100% virus!
0
 
CEHJCommented:
What is the (full and absolute) path in the filesystem to your JDeveloper project?
0
 
gbcbrAuthor Commented:
iMac-Office:StopLimitTradeStation gbcbr$ cd /Users/gbcbr/jdeveloper/StopLimitTradeStationEURUSDCHF60/StopLimitTradeStation/src

Open in new window

0
 
CEHJCommented:
Please post the output of the following (hoping your find command is reasonably Gnu-compatible):


find  /Users/gbcbr/jdeveloper/StopLimitTradeStationEURUSDCHF60 -type f -name log4j.xml -o -name log4j.properties -ls

Open in new window

0
 
gbcbrAuthor Commented:
I delete them from app but it left in classes dir
iMac-Office:src gbcbr$ find  /Users/gbcbr/jdeveloper/StopLimitTradeStationEURUSDCHF60 -type f -name log4j.xml -o -name log4j.properties -ls
3376365        8 -rw-r--r--    1 gbcbr    staff         656 Mar 25 15:12 /Users/gbcbr/jdeveloper/StopLimitTradeStationEURUSDCHF60/StopLimitTradeStation/classes/log4j.properties

Open in new window

0
 
CEHJCommented:
That's the one that counts, and is why you have a problem. Delete it and put the xml file in there
0
 
gbcbrAuthor Commented:
Now it create CHFJPY.log in dir logs, but absolutely raw file which included everything, for 5 sec work already 2.3MB
0
 
CEHJCommented:
You should have various layers of discrimination to thin that out. Can you *attach* Main.java please?
0
 
gbcbrAuthor Commented:
0
 
CEHJCommented:
Is that the one that you're running as the app?
0
 
gbcbrAuthor Commented:
Yes, I did it like this because I have different sources of data which have to start separately. Most probably you need second level class DBFXConnect which create gateway and receive all messages. DBFXConnect.java
0
 
CEHJCommented:
OK, which classes are you interested in debugging?
0
 
gbcbrAuthor Commented:
Let's start from DecisionCenter-CHFJPY-S.java
0
 
CEHJCommented:
Replace the <root> element with


<logger name="CHFJPY.DecisionCenter_CHFJPY_S">
	<level value="debug"/>
        <appender-ref ref="CHFJPY"/> 
 </logger>

Open in new window

0
 
gbcbrAuthor Commented:
client: start logging in
log4j:WARN No appenders could be found for logger (com.fxcm.messaging.util.HostReader).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

Open in new window

0
 
CEHJCommented:
That's ok. You should find your log file is smaller now. If you want to get rid of the warning, put this back in
<root>
        <level value="error" />
	<appender-ref ref="CHFJPY"/> 
    </root>

Open in new window

0
 
gbcbrAuthor Commented:
I found it zero. When I place last snippet it start writing not so much like before, only 2MB for 15 minutes, but also garbage
0-945327692-main
625=Demo
554=74091f9059fcd139dc0d2df5b113635c
336=
923=NewSession-20-945327692-main
924=5
553=DBD11070132001
 (Communicator.java, line 450)
25.03.2011 17:45:33 *DEBUG* PDasSessionAdapter: QueueElement( ISessionStatus *) = {ConnectionName}	{Demo}
{StatusCode}	{2}
{StatusMessage}	{Sending request...}
{ProtocolName}	{HTTP}
{StatusMessageID}	{1}
{StatusName}	{Sending}
{SecureProtocolString}	{S}

 (PDasSessionAdapter.java, line 357)
25.03.2011 17:45:33 *DEBUG* PDasSessionAdapter: UpdateProcessorThread. force (PDasSessionAdapter.java, line 289)
25.03.2011 17:45:33 *DEBUG* PDasSessionAdapter: Status updated on Client (PDasSessionAdapter.java, line 312)
25.03.2011 17:45:33 *DEBUG* HttpCommunicator: <fxmsg v="pdas"><m t="BE" q="0"><f n="112">NewSession-20-945327692-main</f><f n="35">BE</f><f n="625">Demo</f><f n="554">74091f9059fcd139dc0d2df5b113635c</f><f n="336"></f><f n="923">NewSession-20-945327692-main</f><f n="924" t="i">5</f><f n="553">DBD11070132001</f></m>
</fxmsg> (HttpCommunicator.java, line 278)
25.03.2011 17:45:33 *DEBUG* HttpCommunicator: PDAS_HEADER_DEFLATE=
eJyNkD0OgzAMhfeeAnlH2M4PikQyIFi79ASUkIoh0Iqq7fEbqqowdvP3bD0/uwqvuFyyh4Wr7xZwVczuFuoWspsFTByyyQIRgzsOz9OwLOM85Yy5kUpwqQ3nsRunqgjfUaHA1e3GmpPQDHHeJKUkuFKioWBQmdB7Esb36NkHdSYSWqh+5yh0yvFDw+LfLIYlrOeM4NR+fTJo6oYISyTBiPRpFtEdUrH+w70BOHxJ3g==
length=236 (HttpCommunicator.java, line 295)
25.03.2011 17:45:35 *DEBUG* PDasSessionAdapter: QueueElement( ISessionStatus *) = {ConnectionName}	{Demo}
{StatusCode}	{3}
{StatusMessage}	{}
{ProtocolName}	{HTTP}
{StatusMessageID}	{0}
{StatusName}	{Receiving}
{SecureProtocolString}	{S}

 (PDasSessionAdapter.java, line 357)
25.03.2011 17:45:35 *DEBUG* PDasSessionAdapter: UpdateProcessorThread. force (PDasSessionAdapter.java, line 289)
25.03.2011 17:45:35 *DEBUG* HttpCommunicator: ------------ before -------------------

++++++++++++++++++++++++++++++++++++++++
 (HttpCommunicator.java, line 135)
25.03.2011 17:45:35 *DEBUG* PDasSessionAdapter: Status updated on Client (PDasSessionAdapter.java, line 312)
25.03.2011 17:45:35 *DEBUG* HttpCommunicator: ------------ after -------------------
<fxmsg v="pdas"><m t="BF" q="0"><f n="924" t="i">5</f><f n="926" t="i">1</f><f n="112">NewSession-20-945327692-main</f><f n="553">DBD11070132001</f><f n="35">BF</f><f n="336"></f><f n="927">0
DBFXUSDD1;FXCM;DBFXUSDD1;DBFX USD DEMO1
</f><l n="9016"><g><f n="9017">PDAS_SID</f><f n="9018">0</f></g><g><f n="9017">pdas</f><f n="9018">7.19.07272010</f></g><g><f n="9017">price-filtering</f><f n="9018">true</f></g><g><f n="9017">force-messages-delay</f><f n="9018">300</f></g></l><f n="625">Demo</f><l n="386"><g><f n="336">FXCM</f><f n="625">DBFXUSDD1</f><f n="9018">DESC=DBFX USD DEMO1;PIN_SIZE=0;NAME=DBFXUSDD1;PIN_REQUIRED=N;</f></g></l><f n="923">NewSession-20-945327692-main</f></m></fxmsg>
++++++++++++++++++++++++++++++++++++++++
 (HttpCommunicator.java, line 141)
25.03.2011 17:45:35 *DEBUG* PDasSessionAdapter: QueueElement( ISessionStatus *) = {ConnectionName}	{Demo}
{StatusCode}	{0}
{StatusMessage}	{Request sent.}
{ProtocolName}	{HTTP}
{StatusMessageID}	{5}
{StatusName}	{Ready}
{SecureProtocolString}	{S}

 (PDasSessionAdapter.java, line 357)
25.03.2011 17:45:35 *DEBUG* PDasSessionAdapter: UpdateProcessorThread. force (PDasSessionAdapter.java, line 289)
25.03.2011 17:45:35 *DEBUG* PDasSessionAdapter: Status updated on Client (PDasSessionAdapter.java, line 312)
25.03.2011 17:45:35 *DEBUG* PXmlParser: Parsing:
<fxmsg v="pdas"><m t="BF" q="0"><f n="924" t="i">5</f><f n="926" t="i">1</f><f n="112">NewSession-20-945327692-main</f><f n="553">DBD11070132001</f><f n="35">BF</f><f n="336"></f><f n="927">0
DBFXUSDD1;FXCM;DBFXUSDD1;DBFX USD DEMO1
</f><l n="9016"><g><f n="9017">PDAS_SID</f><f n="9018">0</f></g><g><f n="9017">pdas</f><f n="9018">7.19.07272010</f></g><g><f n="9017">price-filtering</f><f n="9018">true</f></g><g><f n="9017">force-messages-delay</f><f n="9018">300</f></g></l><f n="625">Demo</f><l n="386"><g><f n="336">FXCM</f><f n="625">DBFXUSDD1</f><f n="9018">DESC=DBFX USD DEMO1;PIN_SIZE=0;NAME=DBFXUSDD1;PIN_REQUIRED=N;</f></g></l><f n="923">NewSession-20-945327692-main</f></m></fxmsg> (PXmlParser.java, line 111)
25.03.2011 17:45:35 *DEBUG* PXmlParser: start fxmsg (PXmlParser.java, line 137)
25.03.2011 17:45:35 *DEBUG* PXmlParser: start m (PXmlParser.java, line 137)
25.03.2011 17:45:35 *DEBUG* PXmlParser: start f (PXmlParser.java, line 137)
25.03.2011 17:45:35 *DEBUG* PXmlParser: end f (PXmlParser.java, line 200)
25.03.2011 17:45:35 *DEBUG* PXmlParser: start f (PXmlParser.java, line 137)

Open in new window

I don't understand at all what it written, for me it's absolutely useless.
0
 
CEHJCommented:
It's only outputting what you've asked it to ;)
0
 
gbcbrAuthor Commented:
I don't need this garbage, I need only few lines from class which I post
0
 
CEHJCommented:
>>I don't need this garbage

Then don't log.debug it
0
 
gbcbrAuthor Commented:
But how I can get what I need?
It has to be filtered to get only necessary information, otherwise this is useless facility.
0
 
CEHJCommented:
Please attach

a. the log file
b. the current log4j.xml
0
 
tonyguanCommented:
here is a possibly simpler solution:

Why cannot you use output redirection? try to launch it with such command line:

java Youclass >logfile.log 2>&1
0
 
CEHJCommented:
>>here is a possibly simpler solution:

http:#35209338
0
 
gbcbrAuthor Commented:
Still have a questions
0
 
CEHJCommented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.