First of all, you have to create `/data/appdatas/cat` directory, read and write permission is required (0644).`/data/applogs/cat` is also required if you'd like to preserve a debug log, it can be very useful while debugging.
Some [preparations](../_/preparations.md) needs to be done before initializing `cat-client`.
And create a config file `/data/appdatas/cat/client.xml` with the following contents.
<serverip="<cat server ip address>"port="2280"http-port="8080"/>
</servers>
</config>
```
> Don't forget to change the `<cat server IP address>` to your own after you copy and paste the contents.
With all the preparations have done, you must configure the project under your module. The unified project name is placed in the directory specified by the module as a file.
You have to create `src/main/resources/META-INF/app.properties` file, add the following:
And then you have to create the `src/main/resources/META-INF/app.properties` file in your project with the following contents:
```
app.name={appkey}
...
...
@@ -43,6 +28,8 @@ app.name={appkey}
> Only English characters (a-z, A-Z), numbers (0-9), underscore (\_) and dash (-) is allowed in appkey.
Due to java cat client will be lazy initialized, it's not necessary to initialize it manually.
## Quickstart
```
...
...
@@ -68,8 +55,6 @@ try {
### Transaction
log the execution of a transaction
> To avoid of forgetting to complete the Transaction, it's better to surround the Transaction by a try-catch-finally block.
```
...
...
@@ -86,13 +71,16 @@ try {
}
```
we offered a list of APIs to modify the Transaction.
We offered a series of APIs to modify the Transaction.
* addData
* setStatus
* setDurationStart
* setDurationInMillis
* setTimestamp
*addData
*complete
These APIs can be easily used like the following codes.
These APIs can be easily used with the following codes.
```
Transaction t = Cat.newTransaction("URL", "pageName");
...
...
@@ -111,46 +99,74 @@ try {
}
```
There are something you have to know about the Transaction APIs:
There is something you have to know about the transaction APIs:
1.`Duration` will be calculated while you complete the Transaction. (currentTimestamp - durationStart)
2. Although `durationStart` is as same as `timestamp` by default, you can overwrite it.
3.`durationStart` and `timestamp` are different, the first one represents the start time of the Transaction, and the second one only means created time of a message. (Transaction is just a kind of message)
4.`durationStart` won't work when you specified the `duration`.
5. You can call `addData` several times, the added data will be connected by `&`.
1. You can call `addData` several times, the added data will be connected by `&`.
2. It's meaningless to specify `duration` and `durationStart` in the same transaction, although we do it in the example :)
3. Never forget to complete the transaction! Or you will get corrupted message trees and memory leaks!
### Event
#### Cat.logEvent
log the occurrence of an event.
Log an event.
```
# Log a event with success status and empty data.
# Log an event with success status and empty data.
Cat.logEvent("URL.Server", "serverIp");
# Log a event with success status and additional data.
For example, if you called count 3 times in one second (with the same name), we will just summarised the value of them and reported once to the server.
For example, if you have called count 3 times in one second (with the same name), we will just summarised the value of them and reported once to the server.
In case of `duration`, we use `averaged` value instead of `summarised` value.
...
...
@@ -171,16 +187,15 @@ In case of `duration`, we use `averaged` value instead of `summarised` value.
### Log component integration
[log4j](./../../integration/log4j/README.md)
[log4j2](./../../integration/log4j2/README.md)
[logback](./../../integration/logback/README.md)
[log4j](../../integration/log4j/README.md)
[log4j2](../../integration/log4j2/README.md)
[logback](../../integration/logback/README.md)
### URL monitoring integration
[URL monitoring integration with web.xml](./../../integration/URL/README.md)
[URL monitoring integration with springboot](./../../integration/spring-boot/README.md)
### More integration solutions
[URL monitoring integration with web.xml](../../integration/URL/README.md)
[URL monitoring integration with springboot](../../integration/spring-boot/README.md)
more integration solutions refer to the content in the root integration folder.
### Other integration solutions
Please refer to [integration](../../integration) for futhur information.