Using Log4j for writing files
Hello,
Is possible to use log4j for writing files?
For example:
I have an application that produce several report txt files is possible at runtime produce them using log4j features?
Thanks
Did you ever got an answer for this??? I'm starting a new project with ORACLE 9i and the site have a NAS. It will be very helpfull to know if it's possible and how can it be done.
Thank you,
Ulises Feliciano Troche
GIS Analyst
GMT
Similar Messages
-
Need Some Help in Using Log4j for logging
Hi
I am using Log4j for logging in my application . i have problem some areas .
I want to rotate my file on basis of Time. means if my log file name format is HH:MM then after every minute new log file should be created , i am using Size based rotation its working fine.
Plz Tell me which propety i used to set my logfile name like DATeFormat
i tried with this Property but failed
log4j.appender.R.File=%d{HH:MM}
Simlarly i dont want to bound BackupSize
log4j.appender.R.MaxBackupIndex=1000
i want that suppose after 2 Mb automatically start new file and there is no upper bound on that
how can i do that or from where i can see all properties of Log4j ThanksThanks
But in this case i cannot do Size based rotation
These properties not belong to DialyRolling.. class
log4j.appender.R.MaxFileSize=1KB
log4j.appender.R.MaxBackupIndex=1000
what i want is if file size grow with in one minute i create new file using RollingFileApender and if size doesnt grow in one minute and minute cross then next minute file should be created , how can i acheive both of these -
Framemaker uses <$filename> for short file name, can we edit this to change appearance? We do not want the short file name of long filename to include the .fm extension can this be removed or modified to make this happen? In compiling our books it would be helpful to not have this extension appear as it then requires us to create extra files without them.
See: System Variables
-
Sender file adapter - Can I use *.xml for the file name
Hi Gurus,
I have some interfaces where I need to pick the file from a directory. The name of the file will have Data<i>time stamp</i> as the naming convention. Can I use *.xml to pick up my files from this directory?
The help.sap.com documentation says that we can use this naming convention.
<b>
● File Name
Specify the name of the file that you want to process. The name can contain placeholders (*, ? (placeholders for exactly one character)) so that you can select a list of files for processing.
</b>
I tried using *.xml for my file name in the communication channel, XI is not picking up this file.
Please let me know if you have the solution.
Thanks
KalyanMurthy,
Thanks for the reply.
I am using GuildFTP tool as my FTP server. In this tool, all the permissions were given for the file to pick up.
The status of the file is good.
Where in the file adapter configuration I have to select 'Read-only'?
The file adapter is working perfect with the exact name of the file.
Thanks
Kalyan -
Using an * for all file extensions in a class selection parser
Using iFS 1.1.9....
I have successfully gotten a custom document class created using
xml. I have used the following code to set up the parser, etc.
If I use a specific file extension like txt the parser will
upload the file as my custom class. However, if I use * for all
file extensions the parser uploads all files as Document class.
Here is what I am using:
<?xml version='1.0' standalone = 'yes'?>
<!--RegisterQualParser-->
<PropertyBundle>
<Update
Reftype='ValueDefault'>ParserLookupbyfileExtension</Update>
<Properties>
<Property Action = 'add'>
<Name>*</Name>
<Value Datatyupe = 'String'>
oracle.ifs.beans.parsers.ClassSelectionParser
</Value>
</Property>
</Properties>
</Propertybundle>
When the above is uploaded I can go into iFS Manager and see
that the parser has been registered with * as the file extention.
I then upload this:
<?xml version='1.0' standalone = 'yes'?>
<!--RegisterCustomClass-->
<PropertyBundle>
<Update
Reftype='ValueDefault'>IFS.PARSER.ObjectTypeLookpByFileExtension
</Update>
<Properties>
<Property Action = 'add'>
<Name>*</Name>
<Value Datatype='String'>QualDocument</Value>
</Property>
</Properties>
</PropertyBundle>
If I have txt or some other extension for the Name in place of
the * and upload a document it will put the class as
QualDocument. If I have the * it defaults to Document.
Is there a way to have the parser make all uploaded documents
QualDocument instead of Document without doing this for each and
every possible file extension?
Thanks.Using iFS 1.1.9....
I have successfully gotten a custom document class created using
xml. I have used the following code to set up the parser, etc.
If I use a specific file extension like txt the parser will
upload the file as my custom class. However, if I use * for all
file extensions the parser uploads all files as Document class.
Here is what I am using:
<?xml version='1.0' standalone = 'yes'?>
<!--RegisterQualParser-->
<PropertyBundle>
<Update
Reftype='ValueDefault'>ParserLookupbyfileExtension</Update>
<Properties>
<Property Action = 'add'>
<Name>*</Name>
<Value Datatyupe = 'String'>
oracle.ifs.beans.parsers.ClassSelectionParser
</Value>
</Property>
</Properties>
</Propertybundle>
When the above is uploaded I can go into iFS Manager and see
that the parser has been registered with * as the file extention.
I then upload this:
<?xml version='1.0' standalone = 'yes'?>
<!--RegisterCustomClass-->
<PropertyBundle>
<Update
Reftype='ValueDefault'>IFS.PARSER.ObjectTypeLookpByFileExtension
</Update>
<Properties>
<Property Action = 'add'>
<Name>*</Name>
<Value Datatype='String'>QualDocument</Value>
</Property>
</Properties>
</PropertyBundle>
If I have txt or some other extension for the Name in place of
the * and upload a document it will put the class as
QualDocument. If I have the * it defaults to Document.
Is there a way to have the parser make all uploaded documents
QualDocument instead of Document without doing this for each and
every possible file extension?
Thanks. -
Using SQ02 for writing ABAP programs
Hello,
I am using SQ02 coding section for writing some simple ABAP programs, mainly for reporting purposes. I would like introduce more power into my programs, but SQ02/SQ01 reports return "ACCESS_DENIED" when I for example try to call a function (GUI_DOWNLOAD).
Can You advise how to extend SQ02 authorization to enable function calls?
Maybe You know other place from which You can write programs without a developer key?
Thanks,
PawelHi Uday,
do You mean that I have to first make a recording on cg3y using transaction shdb, then create a function module basing on this recording, and then use this function module in my code?
Pawel -
WebLogic server's charset for writing files
Hi!
I have the following situation. Webapp (servlet) instantiates a class, which periodically writes data to files. The data is written to a file using the following code:
fos = new FileOutputStream(outfile);
//Don't wanna specify charset here
fos.write(line.getBytes());
The question is, where do I specify the charset to be used? Weblogic-application.xml has the following definition:
<application-param>
<param-name>webapp.encoding.default</param-name>
<param-value>UTF-8</param-value>
</application-param>
Should this define also the encoding used when writing files, or should I define it in the server startup somehow, or what?Hi!
I have the following situation. Webapp (servlet) instantiates a class, which periodically writes data to files. The data is written to a file using the following code:
fos = new FileOutputStream(outfile);
//Don't wanna specify charset here
fos.write(line.getBytes());
The question is, where do I specify the charset to be used? Weblogic-application.xml has the following definition:
<application-param>
<param-name>webapp.encoding.default</param-name>
<param-value>UTF-8</param-value>
</application-param>
Should this define also the encoding used when writing files, or should I define it in the server startup somehow, or what? -
I have a passport external hard. previously, I used it on windows, then I changed my laptop to mac. Now, It's only read. How can I use it on my mac for copying files on my passport? I don wanna use it on windows again.
If you're not going to use the drive on a Windows machine, you should use Disk Utility (Applications>Utilities folder) to erase the drive and format it as "Mac OS Extended (Journaled)" with a single GUID partition (default):
Good luck,
Clinton -
Anyone using DropBox for LRCAT file?
It seems that when I use my laptop to add keywords to LRCAT, I wind up with a conflicted copy in my dropbox folder...
Is there some way to reconcile or combine the regular lrcat and the conflicted one? Or do I have to just start using the conflicted one?
I know this all has something to do with waiting for all the files to upload and download to DropBox, and I usually don't have a problem since the 2 machines are rarely in use at once...but sometimes I need to shut down quickly or perhaps I miss part of the transfer, so I'm really just checking to see if there is some way to reconcile when I blow it.
Thanks
TomI use Dropbox for my personal catalog. The key is to ensure it's finished fully uploading and downloading before you switch machines, otherwise you end up with conflicted catalogs, as you've found.
There are ways and means of merging the catalogs (export as catalog then import from catalog) or just picking the latest (i.e. delete one copy and rename the conflicted one) but they really do create a lot of extra work, so I'd strongly recommend avoiding that situation.
Also just bear in mind that it's not officially supported by Adobe, so keep regular catalog backups. -
Getting outOfMemory while using Xpath for 6MB file
Hi ,
Requirement:
I have thousands of xml files of variable size (mostly around 5MB), Total size is around 20GB .The structure of xml content is as follows.
filename: xaaaa
<file>
<page>
<title>AmericanSamoa</title>
<id>6</id>
<revision>
<id>133452270</id>
<timestamp>2007-05-25T17:12:06Z</timestamp>
<contributor>
<username>Gurch</username>
<id>241822</id>
</contributor>
<minor />
<comment>Revert edit(s) by [[Special:Contributions/Ngaiklin|Ngaiklin]] to last version by [[Special:Contributions/Docu|Docu]]</comment>
<text xml:space="preserve">#REDIRECT [[American Samoa]]{{R from CamelCase}}</text>
</revision>
</page>
My task is to retrieve the ID , filename in which it exists and the position of node in the page, and i have to write it to a file.
ex: 6:xaaaa:1
My approach:
I am using Xpath for this. The code is as follows.
*/*XPathReader.java*/*
package preprocess;
import java.io.IOException;
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
import javax.xml.parsers.*;
import javax.xml.xpath.*;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
public class XPathReader {
private String xmlFile;
private Document xmlDocument;
private XPath xPath;
public XPathReader(String xmlFile) {
this.xmlFile = xmlFile;
initObjects();
private void initObjects(){
try {
xmlDocument = DocumentBuilderFactory.
newInstance().newDocumentBuilder().
parse(xmlFile);
xPath = XPathFactory.newInstance().
newXPath();
} catch (IOException ex) {
ex.printStackTrace();
} catch (SAXException ex) {
ex.printStackTrace();
} catch (ParserConfigurationException ex) {
ex.printStackTrace();
public Object read(String expression,
QName returnType){
try {
XPathExpression xPathExpression =
xPath.compile(expression);
return xPathExpression.evaluate
(xmlDocument, returnType);
} catch (XPathExpressionException ex) {
ex.printStackTrace();
return null;
XpathReaderTest.java
/* it takes directory name as argument, this directory contains xml file*/
package preprocess;
import java.io.*;
import javax.xml.xpath.XPathConstants;
import org.w3c.dom.*;
public class XPathReaderTest {
public XPathReaderTest() {
public static void main(String[] args) throws IOException{
if (args.length <= 0) {
System.out.println(
"Usage: java PreProcess dir_name"
return;
String dir=null;
if (args.length >= 1) dir = args[0];
int indexno=0;
File directory = new File(dir);
File[] files = directory.listFiles();
FileWriter fstream = new FileWriter("index"+indexno+".txt");
BufferedWriter out = new BufferedWriter(fstream);
XPathReaderTest xt=new XPathReaderTest();
/*for (int index = 0; index < files.length; index++)
System.out.println(files[index].toString());
for (int index = 0,i=1; index < files.length; index++)
/*if(index/100>indexno){
indexno++;
out.close();
fstream = new FileWriter("index"+indexno+".txt");
out = new BufferedWriter(fstream);
xt.extract(files[index].toString(),index,i,out);
System.gc();
out.close();
public void extract(String completepath,int index,int i,BufferedWriter out)
throws IOException
System.out.println(index+" "+completepath);
XPathReader reader = new XPathReader(completepath);
String separator = File.separator;
int pos = completepath.lastIndexOf(separator);
String temp_fname=completepath.substring(0,pos);
pos=temp_fname.lastIndexOf(separator);
String f_name= completepath.substring(pos+1);
i=1;
while(true)
String expression = "/file/page["+i+"]/id";
String id_value= (String) reader.read(expression, XPathConstants.STRING);
if(id_value=="")
break;
out.write( id_value + ":"+ f_name+ ":"+i+ "\n" );
i++;
Problem:
This code works fine for xml files < 6MB, but its giving outOfMemory for 6MB and above file.
I have tried with -Xms256m -Xmx512m option.
Please suggest the work around , or any modification to code that will resolve my problem.
I am new to java world , so problem root cause will be very helpful for me.
ThanksHi ,
Requirement:
I have thousands of xml files of variable size (mostly around 5MB), Total size is around 20GB .The structure of xml content is as follows.
/*filename: xaaaa*/
<file>
<page>
<title>AmericanSamoa</title>
<id>6</id>
<revision>
<id>133452270</id>
<timestamp>2007-05-25T17:12:06Z</timestamp>
<contributor>
<username>Gurch</username>
<id>241822</id>
</contributor>
<minor />
<comment>Revert edit(s) by [[Special:Contributions/Ngaiklin|Ngaiklin]] to last version by [[Special:Contributions/Docu|Docu]]</comment>
<text xml:space="preserve">#REDIRECT [[American Samoa]]{{R from CamelCase}}</text>
</revision>
</page>
</file>My task is to retrieve the ID , filename in which it exists and the position of node in the page, and i have to write it to a file.
ex: 6:xaaaa:1
My approach:
I am using Xpath for this. The code is as follows.
*/*XPathReader.java*/*
package preprocess;
import java.io.IOException;
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
import javax.xml.parsers.*;
import javax.xml.xpath.*;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
public class XPathReader {
private String xmlFile;
private Document xmlDocument;
private XPath xPath;
public XPathReader(String xmlFile) {
this.xmlFile = xmlFile;
initObjects();
private void initObjects(){
try {
xmlDocument = DocumentBuilderFactory.
newInstance().newDocumentBuilder().
parse(xmlFile);
xPath = XPathFactory.newInstance().
newXPath();
} catch (IOException ex) {
ex.printStackTrace();
} catch (SAXException ex) {
ex.printStackTrace();
} catch (ParserConfigurationException ex) {
ex.printStackTrace();
public Object read(String expression,
QName returnType){
try {
XPathExpression xPathExpression =
xPath.compile(expression);
return xPathExpression.evaluate
(xmlDocument, returnType);
} catch (XPathExpressionException ex) {
ex.printStackTrace();
return null;
XpathReaderTest.java
/* *it takes directory name as argument, this directory contains xml file**/
package preprocess;
import java.io.*;
import javax.xml.xpath.XPathConstants;
import org.w3c.dom.*;
public class XPathReaderTest {
public XPathReaderTest() {
public static void main(String[] args) throws IOException{
if (args.length <= 0) {
System.out.println(
"Usage: java PreProcess dir_name"
return;
String dir=null;
if (args.length >= 1) dir = args[0];
int indexno=0;
File directory = new File(dir);
File[] files = directory.listFiles();
FileWriter fstream = new FileWriter("index"+indexno+".txt");
BufferedWriter out = new BufferedWriter(fstream);
XPathReaderTest xt=new XPathReaderTest();
/*for (int index = 0; index < files.length; index++)
System.out.println(files[index].toString());
for (int index = 0,i=1; index < files.length; index++)
/*if(index/100>indexno){
indexno++;
out.close();
fstream = new FileWriter("index"+indexno+".txt");
out = new BufferedWriter(fstream);
xt.extract(files[index].toString(),index,i,out);
System.gc();
out.close();
public void extract(String completepath,int index,int i,BufferedWriter out)
throws IOException
System.out.println(index+" "+completepath);
XPathReader reader = new XPathReader(completepath);
String separator = File.separator;
int pos = completepath.lastIndexOf(separator);
String temp_fname=completepath.substring(0,pos);
pos=temp_fname.lastIndexOf(separator);
String f_name= completepath.substring(pos+1);
i=1;
while(true)
String expression = "/file/page["+i+"]/id";
String id_value= (String) reader.read(expression, XPathConstants.STRING);
if(id_value=="")
break;
out.write( id_value + ":"+ f_name+ ":"+i+ "\n" );
i++;
}Problem:
This code works fine for xml files < 6MB, but its giving outOfMemory for 6MB and above file.
I have tried with -Xms256m -Xmx512m option.
Please suggest the work around , or any modification to code that will resolve my problem.
I am new to java world , so problem root cause will be very helpful for me.
Thanks -
No more than 8Mbps for writing files with TC !
Hello,
I just buy a brand new TC 3To. Internet bandwith is great (more than 80Mbps), but no more than 8 Mbps for writing a file between my mac and the Time Capsule.
How can you explain that ?
ThxTest it with ethernet not wireless if you are on wireless.
What computer are you copying the files to the TC with? What OS and how are you copying?
Is it one large file or a bunch of small files.. the later can be really slow due to time it takes to write allocation table info, cf the actual copy.. the best test is one very large file.. 2GB or so that you copy.. Make sure you do not copy files to the sparsebundle that TM made.. Make sure TM is not running when the files are being copied. -
Using PrintWriter for writing to file
Friends,
I am just begginer in Java programming. I am trying to write a message to the Log file as below. It just opens the file but writes nothing to it. What is missing here ? any help is appreciated.
FileWriter fw = new FileWriter(new File("Readonly.log"));
BufferedWriter bw = new BufferedWriter(fw);
PrintWriter pw = new PrintWriter(bw);
pw.flush();
String message="Check This Out";
pw.println(message) ;
Thanks,Friends,
I am trying to write to a log file in the append
mode. It seems FileWriter would open the file as a
new file each time and overwrite the eralier contents
of it. I am not sure what would be the correct way
to do this.
Can any one help ? I appreciate your time and help
in advance.
Thanks,Then I doubt you're using the proper FileWriter constructor. I'm sure if you pass 'true' for the append parameter, it will not overwrite the contents. -
EasyDMS -using interface for exchanging file props and doc data to classify
For easyDMS there is the possibility to transfer information from file properties to doc data and characteristic information on the DIR. See note 1444113 for more info.
What I would also like to do is as follows: Instead of updating just characeristics from just one class, i would also use it to add the class itself.
This way I could have a JPG class that takes JPG EXIF data, a memo-class that takes the companies defined fields for memo and so on and so forth.
One idea to achieve this could be to have an exit prior to writing the characteristics, that could read one of the values and take the value there and use it to add another class to the document.
The alternative having a document type for each class is not feasible, given that it would just be too many dokument types. Having all possible fields in a single class and using dependencies does not work in easyDMS, so is also discarded.
Comments and ideas appreciated. Just a pointer to where in the code where the variables are actually set in SAP would save me a fair bit of debugging time.
Regards,
Espen LeknesNo, this did not help me.
I'm looking for a answer to specific question relating to how to get the easyDMS-file propererties interface that allows write back of characteristics to also write back a new/updated class.
I know the classification system well enough, it is a specific feature of a specific interface I'm looking for. Unless you have specifically used this interface or the sap gui based one, or know where it is actually called, I doubt it will help me.
Regards,
Espen Leknes -
"Cannot interpret data in file" error while using GUI_UPLOAD for .xls file
Hi,
I have made a program using FM GUI_UPLOAD to upload an .xls file to an internal table. But upon executing ,it gives error "Cannot Interpret data in file". I have seen in other posts people talking about GUI_UPLOAD FM to upload data from excel directly into internal table. Kindly help.
Here is my code. I had tried using different combination for HAS_FIELD_SEPARATOR but still its not working.
In my emp1.xls file , the data in each column is present in the same order as in the internal table. Although the first column in my internal table is NUMC. I dont know if that is causing the problem.
REPORT ZUPLOAD_1.
data: itab TYPE TABLE OF zempl_master WITH HEADER LINE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = 'C:\empl1.xls'
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = itab.
* EXCEPTIONS
* FILE_OPEN_ERROR = 1
* FILE_READ_ERROR = 2
* NO_BATCH = 3
* GUI_REFUSE_FILETRANSFER = 4
* INVALID_TYPE = 5
* NO_AUTHORITY = 6
* UNKNOWN_ERROR = 7
* BAD_DATA_FORMAT = 8
* HEADER_NOT_ALLOWED = 9
* SEPARATOR_NOT_ALLOWED = 10
* HEADER_TOO_LONG = 11
* UNKNOWN_DP_ERROR = 12
* ACCESS_DENIED = 13
* DP_OUT_OF_MEMORY = 14
* DISK_FULL = 15
* DP_TIMEOUT = 16
* OTHERS = 17
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP at itab.
write:/ itab-emp_no,itab-name.
endloop.hi amber22 you need to use the below fm to upload an xls file
FORM EXCEL_UPLOAD .
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = FILENAM
I_BEGIN_COL = 1
I_BEGIN_ROW = 1
I_END_COL = 6
I_END_ROW = 100
TABLES
INTERN = xl_itab.
* EXCEPTIONS
* INCONSISTENT_PARAMETERS = 1
* UPLOAD_OLE = 2
* OTHERS = 3 .
IF SY-SUBRC = 0.
MESSAGE 'DATA UPLOADED SUCCESSFULLY' TYPE 'I'.
ENDIF.
ENDFORM. " EXCEL_UPLOAD -
Hi,
I'm using the class cl_gui_frontend_services to allow the user to copy a file to a specified network drive (using the method file_copy). The user can open the file again, if he double clicks on a row in a ALV table. So far so good, this works already.
But one requirement for this solution is, that the user can not access the directory where the copied files are stored directly.
Now I'm wondering if it is possible to use a specified system user for copying the files? My idea is to switch to the system user just for the method file_copy. I didn't find a method for doing this yet but maybe somebody knows if this is possible.
Thanks and regards,
MartinHi ,
Regarding to your last question; You can get the file list of a specified directory while using OPEN DATASET related commands. After the list populated you make the user select it with the help of a popup screen.
Gets the list of a specified directory's content
CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'
EXPORTING
dir_name = gv_drctry
TABLES
dir_list = lt_dirlist
EXCEPTIONS
invalid_eps_subdir = 1
sapgparam_failed = 2
build_directory_failed = 3
no_authorization = 4
read_directory_failed = 5
too_many_read_errors = 6
empty_directory_list = 7
OTHERS = 8.
Hope it's useful...
Maybe you are looking for
-
Mail: I can only open one email at a time
Using Mail, I have a very strange phanomenon: I can only open one email at a time. E.g. when writing a new email, I cannot open another email for reference. I need to close and save the new email as a draft before being able to open another one. It w
-
I upload an image on transaction SE78 for using with smartforms . Now ,at this moment i need to download it from sap machine to a local machine. We lost the image on the local machine
-
ITunes Emergency 9.0.2
Here's the situation: I spend a lot of time managing my iTunes library, be it buying new music at Best Buy (albums are getting cheaper these days) and putting cover art, years, etc. on them or managing podcasts, subcribing, unsubcribing and the like.
-
Employee Photo (Archive Linik)
hi people, i want to use the employee photos in sap hr (oaoh -> pa20/pa30) in an external application. for that the application needs the "link" to where the photos are stored. it needs the protokoll (ftp or http) and an adress. what is the protokoll
-
Just got a brand new iPad. Is there a way natively or via another app to password protect the Mail application? I'd love to be able to let others use the iPad for internet browsing or games, but with Mail if you click it you can get right into all