Log file in xml format: bad idea?

Hey
Im trying to write a class that will let other classes keep a log on whatever they want to. Whoever wants to write a message to a log file will call a function there, with the specified log name and the message, and my class will write it in xml format into the file.
Simple right? But here's the catch: in order to append a log into the file, I have to read it all first, then create the Element and add it to the root element. That meens that as the file grows, so will the time it takes to read it, and eventually log will take loads of time...
All this would not have happen otherwise, with simple text files, as all I have to do is to open the file for appending, which wouldn't take that much time.
So my questions are: Am I stupid to think this is possible with xml? Should I open the xml file as text file and then manipulate it? Are there any other possibilities?
Thanks for your help - Uzi

Writing logs in an xml file is a very good idea and will later on provide you with a lot of flexibility to perform queries and how u want to display it.
Simple right? But here's the catch: in order to append
a log into the file, I have to read it all first, then
create the Element and add it to the root element.
That meens that as the file grows, so will the time it
takes to read it, and eventually log will take loads
of time...Why do you want to read the whole file for writing new elements. You dont have to do that. I have a simple idea for your problem.
e.g <logfile>
<log>
</log>
</logfile>
So now u want to add another log element. Use RandomAccessFile's length() method to find the size of the file.
Find the size of </logfile> e.g if it is sizeOfString.
Use RandonAccessFile's seek() method as follows
.......seek(lengthOfFile - sizeOfString);
This will move the pointer of the RandomAccessFile to this position. Next step is you can use writeBytes method to further write to this file.
That will increase the speed and performance and would give u great end results of an xml file.

Similar Messages

  • Convert the flat file to xml format.

    hi,
    I need to write a interface program in the R/3  to pull the flat file data from the unix application server and do some manipulation and place back into the unix application server in XML format, From the unix box XML file taken by the XI server.
    pls give me some idea to convert the flat file to XML format, through any function module or any other logic is there...
    with regards,
    Thambee.

    Hi Thambe
    in addition to the above posts
    Program to convert flat file to XML file.
    please download tool from this link:
    http://www.download.com/Stylus-Studio-2008-XML-Enterprise-Suite/3000-7241_4-10399885.html?part=dl-StylusStu&subj=dl&tag=button&cdlpid=10399885
    how to use:
    http://www.stylusstudio.com/learn_convert_to_xml.html
    http://www.sap-img.com/abap/sample-xml-source-code-for-sap.htm
    Flat file to XML
    CONVERTION OF FLAT FILE TO XML : NO OUT PUT FOUND
    Converting Idoc flat file representation to XML
    how to convert flat file into IDOC-XML
    Thanks
    sandeep sharma
    PS ; if helpful kindly reward points

  • How to store xml data into file in xml format through java program?

    HI Friends,
    Please let me know
    How to store xml data into file in xml format through java program?
    thanks......
    can discuss further at messenger.....
    Avanish Kumar Singh
    Software Engineer,
    Samsung India Development Center,
    Bangalore--560001.
    [email protected]

    Hi i need to write the data from an XML file to a Microsoft SQL SErver database!
    i got a piece of code from the net which allows me to parse th file:
    import java.io.IOException;
    import org.xml.sax.*;
    import org.xml.sax.helpers.*;
    import org.apache.xerces.parsers.SAXParser;
    import java.lang.*;
    public class MySaxParser extends DefaultHandler
    private static int INDENT = 4;
    private static String attList = "";
    public static void main(String[] argv)
    if (argv.length != 1)
    System.out.println("Usage: java MySaxParser [URI]");
    System.exit(0);
    String uri = argv[0];
    try
    XMLReader parser = XMLReaderFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
    MySaxParser MySaxParserInstance = new MySaxParser();
    parser.setContentHandler(MySaxParserInstance);
    parser.parse(uri);
    catch(IOException ioe)
    ioe.printStackTrace();
    catch(SAXException saxe)
    saxe.printStackTrace();
    private int idx = 0;
    public void characters(char[] ch, int start, int length)
    throws SAXException
    String s = new String(ch, start, length);
    if (ch[0] == '\n')
    return;
    System.out.println(getIndent() + " Value: " + s);
    public void endDocument() throws SAXException
    idx -= INDENT;
    public void endElement(String uri, String localName, String qName) throws SAXException
    if (!attList.equals(""))
    System.out.println(getIndent() + " Attributes: " + attList);
    attList = "";
    System.out.println(getIndent() + "end document");
    idx -= INDENT;
    public void startDocument() throws SAXException
    idx += INDENT;
    public void startElement(String uri,
    String localName,
    String qName,
    Attributes attributes) throws SAXException
    idx += INDENT;
    System.out.println('\n' + getIndent() + "start element: " + localName);
    if (localName.compareTo("Machine") == 0)
    System.out.println("YES");
    if (attributes.getLength() > 0)
    idx += INDENT;
    for (int i = 0; i < attributes.getLength(); i++)
    attList = attList + attributes.getLocalName(i) + " = " + attributes.getValue(i);
    if (i < (attributes.getLength() - 1))
    attList = attList + ", ";
    idx-= INDENT;
    private String getIndent()
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < idx; i++)
    sb.append(" ");
    return sb.toString();
    }// END PRGM
    Now , am not a very good Java DEv. and i need to find a soln. to this prob within 1 week.
    The next step is to write the data to the DB.
    Am sending an example of my file:
    <Start>
    <Machine>
    <Hostname> IPCServer </Hostname>
    <HostID> 80c04499 </HostID>
    <MachineType> sun4u [ID 466748 kern.info] Sun Ultra 5/10 UPA/PCI (UltraSPARC-IIi 360MHz) </MachineType>
    <CPU> UltraSPARC-IIi at 360 MHz </CPU>
    <Memory> RAM : 512 MB </Memory>
    <HostAdapter>
    <HA> kern.info] </HA>
    </HostAdapter>
    <Harddisks>
    <HD>
    <HD1> c0t0d0 ctrl kern.info] target 0 lun 0 </HD1>
    <HD2> ST38420A 8.2 GB </HD2>
    </HD>
    </Harddisks>
    <GraphicCard> m64B : PCI PGX 8-bit +Accel. </GraphicCard>
    <NetworkType> hme0 : Fast-Ethernet </NetworkType>
    <EthernetAddress> 09:00:30:C1:34:90 </EthernetAddress>
    <IPAddress> 149.51.23.140 </IPAddress>
    </Machine>
    </Start>
    Note that i can have more than 1 machines (meaning that i have to loop thru the file to be able to write to the DB)
    Cal u tellme what to do!
    Even better- do u have a piece of code that will help me understand and implement the database writing portion?
    I badly need help here.
    THANX

  • DME file in XML format in SAP 4.6C

    Hi Experts,
    For a Belgium client, I have a requirement to generate DME file in XML format for payments made to foreign and domestic vendors.  I want to know the following,
    1.  Can DME file be generated in XML format using classic payment medium programs RFFOBE_E and RFFOBE_I.
    2.  If not why and what are the other options.
    3.  I also came to know that there is an options of using Payment medium workbench - through XML format trees BE_BEPDTA and BE_PIBDTA.  But since we are in 4.6C, i am not able to create a payment format.  Is there any support package or patch that is required.
    4.  I tried for SEPA_CT - again a XML format tree but was not very successful as that too was not available in SAP 4.6C.  Is there any way that I can get this done in 4.6C - any support packages or patches available?
    Thanks

    Hi Kaylan,
    could you please share that documentation with me too.
    Thanks, Regards,
    Alex Cardona

  • Writting file in xml format

    Hello guys,
    I am just wondering if i can write to a text file in xml format:
    For example if i want to save the following:
    Avisha 00/06/2000
    The text file should show:
    <record>
    <name>Avisha</name>
    <DOB00/06/200</DOB>
    </record>
    I think i probably needs to use some sort of XML schema, i never done it before and i would appriciate your help.
    Thanks,

    corlettk wrote:
    thomas.behr wrote:
    Well, for simple cases, such as your example, just create an appropriate String and write that to your file.
    For more complex cases, create a org.w3c.dom.Document (using DocumentBuilder and DocumentBuilderFactory), create the appropriate structure and use a javax.xml.transform.Transformer (created via TransformerFactory) to convert your Document from a DOMSource to StreamResult.I'm not a fan of the DOM solution... It's slow and very memory hungry... Goog for small datasets.
    @OP If you can, I recommend using an XMLBinder (like [XML-Beans|http://xmlbeans.apache.org/] jusr for example) to both read and write all your XML.Errr, XMLBeans and the like will still be using DOM under the covers, so the memory issue is still as relevant as before. Happily, this turns out to be "not as much as you probably think" anyway. So the decision is a design one. Do you have schemas for this XML? You don't? Ah well, a binding framework's out of the question anyway. What are you doing with it? ("Processing it" isn't an answer). Where is it coming from? ("my codez" isn't an answer). What format need it be in? ("XML format" isn't an answer)
    Building a DOM tree and serializing it isn't necessarily all that stupid an idea

  • Convert gzip files into XML format

    We have a requirement where we receive gzip files. These files are zipped file containing base64 binary format csv files. We would have to convert these files into XML format. Please let me know any of the following.
    1. Is there any Xpath query or XSL function (somthing similar like doTranslateFromNative() ) to convert from gzip files to XML format.
    2. If we need to unzip the zipfile outside fusion, then java code piece to unzip the gzip file. I guess after that we can use the usual doTranslateFromNative() function to translate to XML format, since after unzipping the gzip file, they are base64 binary formats.
    Thanks in advance,
    Toms

    There is an option to do pre-processing and post processing of Files when using File adapter. You need to create a valve which will first do pre processing and send the output to FileAdapter.
    You can get more information here:
    http://docs.oracle.com/cd/E23943_01/integration.1111/e10231/adptr_file.htm#CACDHGGG
    under section: 4.2.14 Pre-Processing and Post-Processing of Files
    Essentially you will use Java to unzip the file first and then the unzipped content will be passed to the adapter.

  • STORING DATA IN FILE IN XML FORMAT THROUGH JAVA ?

    HOW TO STORE DATA IN FILE IN XML FORMAT THROUGH JAVA PROGRAM?

    Have you looked into JAXB?
    That is a new way of processing XML into Java classes or visa versa.
    Otherwise, there are a lot of other XML related tools for Java in the -XML link on the left side of the page.

  • Why does photoshop elements 10 back up files in xml format

    I am trying to backup my catalog including tags to my external hard drive. When I do the files are all in XML format. When I attempt to open using Photoshop
    i get "wrong type of file" or they are just a lot of code. What is going on. Where are the pictures?

    I downloaded them into the same folder, and once that was done, I did as you said and opened PhotoshopElements_10_LS15.exe. It asked for my serial number and everything, seemed as though it was installing, and asked to restart in order to complete the process. I restarted the computer, and...I don't see Adobe Photoshop Elements 10 anywhere. There is a folder on my desktop that goes by the name of Photoshop Elements 10, but it only contains data files and things that I can't use. It's not the actual software....
    What should I do?

  • Logged changes in XML format

    Hi,
          I am trying to convert the logged changes into XML file.But the contents are not coming up correctly.Please help me in solving out this issue.
    I have coded is like this :
    CALL FUNCTION 'HR_INFOTYPE_LOG_GET_LIST'
    EXPORTING
       tclas                    = 'A'
       begda                    = sy-datum
       endda                    = sy-datum
       auth_check               = 'X'
      USE_ARCHIVE              = ' '
    IMPORTING
      SUBRC                    =
      TABLES
      PERNR_TAB                =
      INFTY_TAB                =
        infty_logg_key_tab       = test
      DATUM_TAB                =
      UNAME_TAB                =
    LOOP AT test INTO wa.
      CALL FUNCTION 'HR_INFOTYPE_LOG_GET_DETAIL'
        EXPORTING
          logged_infotype        = wa
         auth_check             = 'X'
      USE_ARCHIVE            = ' '
    IMPORTING
      SUBRC                  =
        TABLES
          infty_tab_before       = test1
          infty_tab_after        = test2
         fields                 = test3
      CHECK sy-subrc = 0.
      ENDLOOP.
    And i am appending  INFTY , PERNR from TEST1 table and FNAME ,NEWDT from TEST3 table into one new internal table called struct and converting that internal table contents into xml.
    For XML conversion*********************************
    CALL TRANSFORMATION ('ID')
    SOURCE tab = struct[]
    RESULT XML xml_out1.
    CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
      EXPORTING
        text            = xml_out1
    IMPORTING
      LENGTH          = lv_length
      TABLES
        ftext_tab       = itab1.
    CHECK sy-subrc = 0.
    After downloading i am getting the xml file like this :
    <?xml version="1.0" encoding="UTF-16"?>
    -<asx:abap version="1.0" xmlns:asx="http://www.sap.com/abapxml">-<asx:values>-<TAB>-<item><INFTY>0002</INFTY><PERNR>00070297</PERNR><FNAME/><NEWDT/></item>-<item><INFTY/><PERNR>00000000</PERNR><FNAME>ITXEX</FNAME><NEWDT/></item>
    But i want in this way:
    <?xml version="1.0" encoding="UTF-8"?>
    -<NewDataSet> -<PA0002> <PERNR>8000</PERNR> <TITEL>DLEM 6</TITEL> <VORNA>Raj</VORNA> <NACHN>Halli</NACHN> <NAME2>RB</NAME2> <INITS/> <RUFNM/> <SPRSL/> <GESCH/> <GBDAT/> <GBORT/> <GBLND/> <NATI0/> <GBDEP/> <NATI2/> <NATI3/> <FAMST/> <FAMDT/> <ANZKD/> <KONFE/> <BEGDA/> <AEDTM/> </PA0002>
    Regards,
    Helma

    Hi Patlolla,
    Goto SPRO : Personnel Administration -> Tools -> Revision -> Set up change document.
    There, add IT 0021 as an infotype to be logged.
    Best Regards,
    Dilek

  • How to convert CSV/Text files to XML format

    Hi,
    I am trying to convert a .csv/.txt(Flat) file(s) to XML format. How can i achive this?
    Ex: I want to convert this text file to XML.
    Book#      first name                                last name                               ID#                 ID1#      F#
    B99          FRISBY                                  NASIER                                  LUCJ A         A 3127      1    
    B131         HAWKINS                              MICHAEL                               LUCJ A         A 3129       2    
    B313         KING                                     JOSHUA                                 CUCJ I         I-DORM      10   
    B307         GRAVES                               KIMBERLY                              NUCJ F         F-DORM     24-FL
    R469         HEATH                                  DARRELL                                SUCJ A         A 3132       1    
    R212         PEREZ                                  DARRELL                                SUCJ A         A 3133       2    
    R62          COFFEY                                GREGORY                               NUCJ HC      H C 3112    3FLOOR
    R215         BLACKWELL                          DEREK                                   LUCJ OOW     W 01       1     Could anyone please suggest me if we have any open source java api to acheive this?
    Thanks,
    Srikanth.

    Have a look at [http://servingxml.sourceforge.net/|http://servingxml.sourceforge.net/] or [http://www.talend.com/|http://www.talend.com/]

  • Log File in SAP B1

    As the log file (in XML format) is generated by the SBO client application currently,it is not possible to
    maintain a consolidated log file in License Server/SBO Server now, so will SAP lanuch a new function to consolidate all the log file simultaneously in the server for the coming version, so a better control will be provided for the administrator to view all the system log for each user.
    Thanks.

    Hi Tien,
    Please visit performance section under:
    https://websmp108.sap-ag.de/~form/sapnet?_SHORTKEY=01100035870000707558&_SCENARIO=01100035870000000183&_ADDINC=&_OBJECT=011000358700000622642008E
    Regards,
    Paul

  • Can I generate .txt / .log file from Oracle Diagnostic Logging?

    Hi all,
    on my application I need to limit the size of application log, I've read this [http://download.oracle.com/docs/cd/B25221_04/web.1013/b14432/logadmin.htm#CHDJHHHB|http://download.oracle.com/docs/cd/B25221_04/web.1013/b14432/logadmin.htm#CHDJHHHB] that using ODL, but generated file is .xml, but I need .log / .txt file. How can I do this??
    thanks in advance.
    Regards,
    Kahlil

    ODL generates log files in XML format only. Using ODL you can not have plain text format log files. You have to decide what is more desired - log rotation (that ODL provides) or text format (which is the default, non-ODL, format). If text format is more desired than don't enable ODL and write your own shell script to rotate application log (but that can only be done while OC4J is down).
    At the same time if you are concern about readability of log file (i.e. text format is easier to read vs. xml format) than you might consider using one the log viewer tool (log viewer in EM or printlogs command line) provided by Oracle. Both of these tools help you view the logs in much more readable format than just looking at xml format log file.
    (printlogs utility is under $OH/diagnostic/bin directory. Run "printlogs -help" to read about it).
    Hope this helps.
    Thanks
    Shail

  • Ack file date and time format is same as in source xml format

    Hi...All,
    1) my scenario is file-rfc-file using BPM,
    we are getting file in xml format from source along with timestamp and this data will be going to R/3 and the acknowledgement (success or failure) file will be sending back to source system.
    in this sceneario we have to fulfill in the follwing client requirement
    File1.<same File1 date and time>.XML
    Is it possible to make it as the following? if it is possible
    could u please let me know how to fulfill the follwing requirement.
    ACK File1.<same File1 date and time>.XML
    Where <same File1 date and time> format = u2018YYYYMMDDhhmmssu2019 .
    2) Is the XML file name visible in the SAP-XI monitoring screen and will it help to trace the messages?
    thanks in advance,
    Pasi.

    Hi,
    I didnot under stand your first question coulf you be more specfic.
    2. Ans : In general , we will follow the below steps
    --First we we check for the file is picked or no, if not see the Sender side CC parameters like mode and path details
    --If file was picked then we need to check whether we are using the File content conversion parameters or not if yes we need to check the FCC parameters ,
    Goto RWB-Channelmonitoring by the following link
    http://host:port/mdt/channelmonitorservlet
    select the sender side CC name and check for errors
    If no errors in above, goto SXMB_MONI for Integration Engine xml processing , check for successful or error occured black or red color
    --if success in SXMB_MONI then we need to check in RWB as above channel monitor now select the receiver side CC
    If no errors then check for output file is placed intarget or not
    Please reward points if it helps
    Thanks
    Vikranth

  • How to SaveAs the MSword file into xml file format using Java APIS?

    Hello all,
    I want to convert MSword file into Xml format using java APIS or any other inbuilt APIS that i can integrate in Java code.

    Sorry, that doesn't make much sense.
    The XML you gave is a configuration file for txt2xml utility. It doesn't represent the output format.
    Are you a user of this utility?

  • Reading String (Name-Value) from text file into XML

    Hi,
    I have a requirement for reading a text file and converting each entry of that text file into XML format. I have not came across such thing yet so looking for some ideas. I am using SQL Server 2005 and here is a sample entry from my source text file,
    Jun 4 14:31:00 zzzz64x02 fff:
    INPUT(ty=XYZ,Prefix=15063,dn=78787878787878,sgk=100.139.201.48,xxn=87878,ani=656565656565,ogrp=F7ZX05,ogtxt=NNNNN,ogx=NNNNN,oci=0xe00ac,ogi={NOA=INT,BC=1,SIG-TYPE=ZIP});
    PROCESS(ty=0x100000,cu=32880,Name=XOXOXOX,pc=88017,pd=24,dd=880175,pk=880175,rd=115472,ca=BGD,reg=RW,cdp=1,ai=245359,grp=2648,sl=9);
    OUTPUT(ty=XXXX,ret=0,rl=
    {i=1,su=99999,rizID=61084,skid=06,truckgp=1084,dd=8801,dn=78787878787878}
    I will get multiple entries like this in my source text file which I have to convert into XML (using TSQL).
    Any help will be useful.
    Regards.
    'In Persuit of Happiness' and ..... learning SQL.

    And I'm telling you that this is a bad option. You would use the vaccum cleaner to wash the dishes, would you?
    If you for some reason would do this task in SQL Server, you would implement it as a CLR stored procedure, but from what you have said I don't understand why you would do this server-side at all.
    What's wrong with the current C# solution?
    Erland Sommarskog, SQL Server MVP, [email protected]
    Got it.  I was just looking for the available options, nothing wrong with my C# solution. And yes, I don't use vacuum cleaner to wash dishes.
    'In Persuit of Happiness' and ..... learning SQL.

Maybe you are looking for