echo'{"version": "1.1","host":"example.org","short_message":"A short message that helps you identify what is going on","full_message":"Backtrace here\n\nmore stuff","level":1,"_user_id":9001,"_some_info":"foo","_some_env_var":"bar"}' | gzip | nc -u -w 1 127.0.0.1 12201
<?php
// short_message will contain string representation of ['test1' => 123, 'test2' => 456],
// no full_message will be sent
Yii::info([
'test1'=>123,
'test2'=>456,
]);
// short_message will contain 'Test short message',
// two additional fields will be sent,
// full_message will contain all other stuff without 'short' and 'additional':
// string representation of ['test1' => 123, 'test2' => 456]
Yii::info([
'test1'=>123,
'test2'=>456,
'short'=>'Test short message',
'additional'=> [
'additional1'=>'abc',
'additional2'=>'def',
],
]);
// short_message will contain 'Test short message',
// two additional fields will be sent,
// full_message will contain 'Test full message', all other stuff will be lost
Yii::info([
'test1'=>123,
'test2'=>456,
'short'=>'Test short message',
'full'=>'Test full message',
'additional'=> [
'additional1'=>'abc',
'additional2'=>'def',
],
]);
方式二:使用 \yiier\graylog\Log
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
\yiier\graylog\Log::info(
'Test short message',
'Test full message'
);
\yiier\graylog\Log::info(
'Test short message',
'Test full message',
[
'additional1'=>'abc',
'additional2'=>'def',
],
'graylog'
);