Create log file with custom name - cakephp

How to create log file with custom file name in cakephp 2.5.1.
I am written following code
$this->log("Data : ".print_r($this->data,true),'debug');
It create's debug.log file in tmp/log folder but when I write custom name like
$this->log("Data : ".print_r($this->data,true),'data');
This code do not create any log file. My Question is how to create log file with custom name?

Same answer as for the other question: Start reading the manual. A huge part of the profession is to read documentation.
Changed in version 2.5.
CakeLog does not auto-configure itself anymore. As a result log files
will not be auto-created anymore if no stream is listening. Make sure
you got at least one default stream set up, if you want to listen to
all types and levels. Usually, you can just set the core FileLog class
to output into app/tmp/logs/:

Related

How to get the log file of an OMNeT++ simulation

Is there any way to get automatically the content of the log view in OMNeT++ presented below into a file (any type, even in a text file)?
Note that I am not talking about the .elog file generated automatically by OMNET++.
No, there is no way to automatically write the content of Log Viewer in Message mode.

File upload and attach in Acumatica

I'm actually new in Acumatica Framework. I'm having some issues to understand how to attach the file. The problem is that in this answer Attach file to data row they talk about
PXNoteAttribute.SetFileNotes(Base.Caches[typeof(DAC)], dacRecord, file.UID.Value);
I do not understand what do they refer about "Base.Caches[typeof(DAC)], dacRecord", I've already saved the file but the step of setting the file is my problem...
You need to provide the Cache object corresponding to the type of your Record and the Record itself. For example if you need to attach file to SOOrder you will provide values like below:
var currentSOOrder = soOrderEntry.Document.Current;
PXNoteAttribute.SetFileNotes(soOrderEntry.Caches[typeof(SOOrder)], currentSOOrder , file.UID.Value);

can we drop a file to a folder location automatically using camel,or at a set period of time(not intervals)?

Iam trying to automate the testing of a java bundle,Which will process once a file is dropped in a particular folder.
can we drop a file to a folder location automatically using camel,or at a set period of time(not intervals)?
is this possible purely by camel or should we incorporate other frameworks?
sure, you can use the camel-file component to produce (create files somewhere) and consume (read/process files from somewhere) and optionally control the initial/polling delays easily with attributes...
here is a simple example of consuming->processing->producing
from("file://inputdir").process(<dosomething>).to("file://outputdir")
alternatively, you could periodically produce a file and drop it somewhere
from("timer://foo?fixedRate=true&period=60000").process(<createFileContent>").to("file://inputdir");
Although camel could do this by creating a timer endpoint, then setting the file content and writing to a file endpoint, my answer would be to simply use a bash script. No camel needed here.
Pseudo bash script:
while [ true ]
do
cp filefrom fileto
pauze 10s
done

File property in RollingFileAppender - logback Configuration

I have the following RollingFileappender in my logback configuration file.
<appender name="RollingFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>C:\Files\MyLogFile.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>C:\Files\MyLogFile.%d{yyyy-MM-dd}.log</FileNamePattern>
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<encoder>
<pattern>%date %level [%thread] %logger{60} [%file:%line] %msg%n</pattern>
</encoder>
</appender>
It does write to MyLogFile.log but does not append the date as specified in the FileNamePattern.
There is a simular question, but it never answered my confusion.
I should omit the file property.
Why is the file-property then usefull, because it seems to overrule the rolling-file activity.
This confuses me. Did is get something wrong?
The file property, when used along the fileNamePattern one, will define the name of the ACTIVE file, and only archived files will have that pattern as name. When the active file is rolled, a new archive file will be created with that name. From chapter 4 in the manual:
Note that the file property in RollingFileAppender (the parent of TimeBasedRollingPolicy) can be either set or omitted. By setting the file property of the containing FileAppender, you can decouple the location of the active log file and the location of the archived log files. The current logs will be always targeted at the file specified by the file property. It follows that the name of the currently active log file will not change over time. However, if you choose to omit the file property, then the active file will be computed anew for each period based on the value of fileNamePattern.
So it is useful when you want to have a fixed name, for example, if you need to send the active file programmatically and don't want to guess what the file name would be for the current date.
Also notice that file is a property inherited from the regular FileAppender.

How to deny creating empty log file with be.file in Pantheios?

1)be.file backend has a feature - messages added before _be_file_set_filename() are not lost and will be appended to log later.
2)_be_file_set_filename opens file immediately => if no entries was added, emty file will be created
Question: how to suppress creating empty file (create file only when first log entry appended) and save feature 1) ?
Use the flag PANTHEIOS_BE_FILE_F_DELETE_IF_EMPTY, described here.
My guess is that the file is created synchronously to avoid the less-desirable situation where a log file cannot be created while a process is running. If you really want that, maybe add the functionality and supply back to the project?
I've solved this problem by writing custom backend - wrapper over be.file

Resources