Server Logs & MySQL
#1

Hello again, folks! So lately I've noticed I'm not doing all I can to make my script as "unique" as I had originally planned. I guess using "fwrite" to create and store server log's is probably a bad idea. I'm still not sure how it would work, so could someone please explain to me how I would use MySQL to create logs? I'd like to log commands, bans, kicks, and all types of chat, including /o, /b, /me, /do, etc... So... How? Thanks!
Reply
#2

Using MySQL to log that kind of information would be much slower than using files, since you would be writing information quite often. It would be much more effecient to log certain information to individual files in a nice format for easy reading later.
Reply
#3

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Using MySQL to log that kind of information would be much slower than using files, since you would be writing information quite often. It would be much more effecient to log certain information to individual files in a nice format for easy reading later.
+1, MySQL is not the best option unless you need the logs for a online log page or something.
Reply
#4

Just make sure that you thread you your queries and you are good to go. The big advantage of having logs stored in database is that you can easily find anything you are looking for.
Reply
#5

Quote:
Originally Posted by JaTochNietDan
Посмотреть сообщение
Using MySQL to log that kind of information would be much slower than using files, since you would be writing information quite often. It would be much more effecient to log certain information to individual files in a nice format for easy reading later.
I agree, like make a folder in your scriptfiles folder, like Logs, then make the script put text files for logging.

Ex: Chat.txt, when you open it up, it would log the chat, and then ban.txt would log the bans, and so on.

Reply
#6

Quote:
Originally Posted by Sergei
Посмотреть сообщение
Just make sure that you thread you your queries and you are good to go. The big advantage of having logs stored in database is that you can easily find anything you are looking for.
I would be careful with that, I had a wonderful idea of threading all queries. Little did I know, my database supports only up to 10 connections and most queries simply failed, even those not threaded.
In other words, make sure your mysql server supports indefinite number of connections for one user.
Reply
#7

Okay, thanks for all the replies and recommendations guys!


Quote:
Originally Posted by mick88
Посмотреть сообщение
I would be careful with that, I had a wonderful idea of threading all queries. Little did I know, my database supports only up to 10 connections and most queries simply failed, even those not threaded.
In other words, make sure your mysql server supports indefinite number of connections for one user.
I know you told me once before that you "mirrored" your logs to you're control panel. Is this possible with .txt files?
Reply
#8

Maybe you could download the (temp) file using the FTP and then parse it to the website for example, and later just delete it. Probably it would be slow IMO, but thats the only solution I get.
Reply
#9

As Sergei said, as long as you thread queries, then you'll have little or no problems (paraphrased, of course). Aside from that, I'd assume that an INSERT query would be faster to process as it's sending data, not retrieving data and having to parse it through 3-4 different formats of variables (MySQL load into some form of plugin string > being split by '|' > being loaded from the plugin into pawn).

Quote:
Originally Posted by Luka P.
Посмотреть сообщение
Maybe you could download the (temp) file using the FTP and then parse it to the website for example, and later just delete it. Probably it would be slow IMO, but thats the only solution I get.
MySQL would be faster than that.

Quote:
Originally Posted by mick88
Посмотреть сообщение
I would be careful with that, I had a wonderful idea of threading all queries. Little did I know, my database supports only up to 10 connections and most queries simply failed, even those not threaded.
In other words, make sure your mysql server supports indefinite number of connections for one user.
I've never needed to use more than 1 connection, so yeah, I haven't experienced what you've had.
Reply
#10

Quote:
Originally Posted by Calgon
Посмотреть сообщение
I've never needed to use more than 1 connection, so yeah, I haven't experienced what you've had.
I was using 1 connection al right, but when you thread, the script could be sending multiple queries at once thats where problem began for me, after I un-threaded them, everything was back to normal.

I did 'mirror' the data, but that was when I was switching to mysql. All I did was I was saving data (players, vehicles, houses) to both database and file mysql, but script read data only from file, but that was for short time.

Anyways, if you want to log some data into database, that's fine, I log a lot of things there, you can use threading or INSERT DELAYED, but if you are using ServerFFs's mysql database same as me, you may experience same problems with threads
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)